开发者

Symfony 'exists' validator

Is there a validator in symfony which checks if a开发者_高级运维 given thing exists in the db?

I need it for forgetten password, so it has to be valid when the email address exists

Thanks


There isnt one by default but it should be easy to build. Take a look at SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/validator/sfValidatorDoctrineUnique.class.php for an example of interacting with the db in a vlaidator (assuming youre using Doctrine). You might also want to look at how sfDoctrineGuardPlugin implements this... I dont recall if its in a validator or as a separate part of the action but i would look to this as a best practice on this type of functionality within symfony since its the "standard" way to implement user authentication and permissions.


Everything you need is already included in symfony.

You may choose based on your ORM

  • sfValidatorDoctrineUnique
  • sfValidatorPropelUnique

Both are well documented on symfony's homepage.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜