purekid / mongodm

MongoDB ORM that includes support for references,embed and multilevel inheritance.
MIT License
200 stars 47 forks source link

Add validators for attributes #56

Open purekid opened 10 years ago

purekid commented 10 years ago

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')

    );
jrschumacher commented 10 years ago

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.

wildsurfer commented 10 years ago

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

jrschumacher commented 10 years ago

@wildsurfer yea that looks good @purekid thoughts?

purekid commented 10 years ago

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

macedd commented 10 years ago

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.