What is the difference between Invariants and Validation Rules?

Absolutely, validation is the process of approving a given object state, while invariant enforcement happens before that state has even been reached.

A corollary is that invariant enforcement is best performed by the thing that is being mutated (or created) itself, like a self-protection reflex, whereas validation is usually done by a third party.

The Always valid school of thought advocates the use of invariants over validation. I think it goes perfectly with DDD and Aggregates.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)