Castle Active Record - Validation and Relationships

275 views Asked by At

I have two models: foo and bar. Foo has a bar object. Foo and bar have validation rules. If I call Foo.isValid() it doesn't validate bar too. I need to validate bar with isValid. How does Castle Active Record Validation work for relationship? Do you have any example or documentation? The official site has a poor documentation and nothing about validations and relationships. Thank you.

1

There are 1 answers

0
Mauricio Scheffer On

IIRC ActiveRecord validates nested components (i.e. value types), but not relationships.

If it did, it would have to check for proxied objects. If it initialized proxied objects it would be pretty catastrophic, potentially fetching the entire database. If it didn't, then it would break proxy transparency, and validation would be somewhat unpredictable or at least very tricky. Either way, it's very probably not what you want. But if you really know what you're doing, you can override the default validator.