开发者

Castle Active Record - Validation and Relationships

开发者 https://www.devze.com 2023-02-28 18:38 出处:网络
I have two models: foo and bar. Foo has a bar object. Foo and bar have开发者_Go百科 validation rules. If I call Foo.isValid() it doesn\'t validate bar too. I need to validate bar with isValid. How doe

I have two models: foo and bar. Foo has a bar object. Foo and bar have开发者_Go百科 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消