sokil / php-mongo

MongoDB ODM. Part of @PHPMongoKit
http://phpmongokit.github.io/
MIT License
242 stars 46 forks source link

when validating a structure: "Validator with name unique not found" exception #142

Closed sagarguhe closed 7 years ago

sagarguhe commented 7 years ago

I was trying to validate a structure and as per document found a method Document::beforeConstruct() to add a validator namespace. Which will work if used to validate Document but will not work if used to validate structure, because Structure doesn't have such method. So the Structure::getValidatorClassNameByRuleName() method will always look for a validator class in \Sokil\Mongo\Validator\ namespace.

So I think Sokil\Mongo\Structure should also have beforeConstruct() to support global Class level validators.

sokil commented 7 years ago

Done