I have a basic REST controller to create a new, basic "message" (subject & body) that can have attachments. Message & Attachment are models, since a message has many attachments.
In the Message model, in createMessage() method, I'm running:
self::validate( 'create' )
to validate the fields for Message.
In that same method, I need to create attachments & validate them too (else cancel saving the message on failure). When I try to do Model_Attachment::validate('create') it throws an error about how validation is already instantiated.
I used Validation::instance() which worked, but I'm not sure how it knows to validate the attachments model. It doesn't error, but I feel like this isn't the correct way to do this?
If you want to use the model for validation, you should look into the Validation observer. It runs automatically on save(), based on the validation rules defined in $_properties.