开发者

Castle Active Record - Validation and Relationships

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜