Closed mbroadst closed 8 years ago
If we are going to do this we need to move the config off of the object as well. Then when the object is passed in we get the reporter and the config for that object.
@PWKad agreed, this was more to start showing intent through code to pair with the conversation. A more complete example would look (I think) something more like:
validator = injectedValidator
.ensure('firstName').length({ minimum: 3 }).required()
.ensure('lastName').length({ maximum: 5}).presence().required();
...snip...
validator.validate(obj);
I'm not really thinking so much about the implementation right now, just brainstorming what the user facing api might be.
@PWKad Has this issue been addressed in some other design work?
@EisenbergEffect it was part of the plan proposed by @PWKad and @jdanyow, however we seem to be bogged down by discussion over on #33. I'll close this for the time being, as it was only meant to serve as the basis for conversation
This is mostly meant to serve as a basis for conversation about refactorings for the validator in general pairing with this comment: https://github.com/aurelia/validatejs/issues/33#issuecomment-217710788.
As you can see this begins to decouple the validator from the data it is validating. The refactor is incomplete as the metadata is still stored on the model (further changes down this path would have to be discussed), but I think it begins to exemplify what I was talking about in the comment linked above.
Thoughts?