mongodm icon indicating copy to clipboard operation
mongodm copied to clipboard

Add validators for attributes

Open purekid opened this issue 11 years ago • 5 comments

Validating data with specify rules of attribute , throw error messages when validating failed.

Inspired by: http://laravel.com/docs/validation#rule-in


    protected static $attrs = array(

        'age' => array('type'=>'integer','rules'=>'required|min:5|max:100'),
        'gender' => array('type'=>'string','rules'=>'in:male,female')

    );

purekid avatar Mar 28 '14 12:03 purekid

Hmm interesting concept. Is there a way we can include a 3rd party library of validators to use? I don't know of any off hand but I will look.

jrschumacher avatar Mar 28 '14 12:03 jrschumacher

@jrschumacher what about this one https://github.com/symfony/Validator?

wildsurfer avatar Mar 28 '14 13:03 wildsurfer

@wildsurfer yea that looks good @purekid thoughts?

jrschumacher avatar Mar 28 '14 13:03 jrschumacher

That looks good,let's find a way to extend it.

purekid avatar Mar 29 '14 05:03 purekid

BTW, just arrived and this is the best PHP Mongo Library I've found...

Just one question (out of docs): @purekid how is validation currently working? I'm looking for save and find data casting to make the usage more error prone.

macedd avatar Apr 24 '14 15:04 macedd