I am thinking of using Specification pattern for validation purposes. The hard thing is how to tell the user why some Specification was not satisfied. What if the Spec
I had the same problem. I create Validation decorator for Specification (code is JAVA).
interface Validator{
Respond validate(T t)
}
class abstract ValidationSpecificationDecorator implements Validator {
Specification spec;
ValidationSpecificationDecorator(Specification spec){
this.spec = spec;
}
public Respond validate(T t) {
Respond respond = new Respond();
if(!spec.IsSatisfiedBy(t){
respond.add(error(t));
}
return respond;
)
public abstract Error error(T t);
}