resource = Resource.new attributes
resource.valid? # => true | false
resource.save # => true | false Will raise adapter errors in case of Inconsistency
resource.errors # => ErrorSet (cached) will not reflect adapter errors
resource.attribute=invalid_value
resource.errors # Same error Set as above, will not reflect attribute change
- Command query seperation is low
- Errors must not reflect the latest validation results
- No central point to catch exceptions from adapters
Naming is not authoritative.
The traditional API is left untouched. Only Resource#validate will be called more often.
- ErrorSet will be upgraded to something like ValidationState
- Resource#valid? is implemented as resource.validate.valid?
- Resource#errors is aliased to Resource#validate, it does not cache anymore
- Resource#{save,delete,update} is left untouched
- before :valid? will be depreciated. IMHO it hides bad model design.
- No way to navigate from a resource to an outdated validation result anymore.
resource = Resource.new attributes
state = resource.validate # Resource#validate returns a more powerful ErrorSet (ValidationState?)
# This state carries the same information like #errors before,
# but can also be responsible to persist the resource with
# adapter exception converison.
state.save # => true | false
Emmanuel: Pls enter your idea here!!!