I have a Orm model that contains _properties fields and validation rules, i know that i can call valid function for true/false result or valid function will be called in save function, but is it possible to get validation object of that orm object? like crud models, ex.
$validation = Model_Mymodel::validation();
if( $validation->run())...
other question is that, is it possible to get errors on valid() functions call?
If you use the validation observer, it will throw a ValidationFailed exception if the validation fails.
The exception object has a get_fieldset() method which you can use to retrieve the fieldset that was generated for the model object.
A fieldset object has a validation() method which returns the associated validation object. You can call the error() method to retrieve all validation error objects.
in this forum post, (last reply) has a simple way to get validation object, you can use normal validation rules in _properties but also can define and use rules more flexible,
That example is a copy of the way you do validation with Model_Crud, and copied to an ORM model.
It works, it is interchangable with Model_Crud, but it is not integrated in the ORM model, it doesn't use the model properties, and you can't combine it with for example the typing observer.
It also requires manual validation, all that does is a method to define the validation object. ORM model validation runs completely automaticly, when you save the object.