Added support for user defined custom validation callback #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change adds the ability for a user to define a callback to test the property against whatever they want.
the callback is passed 3 arguments: key, value, and the model's scope. This is awesome because you're able to compare against another property (or properties) on the model. return a truthy value back and it will pass the validation or return a falsy value back to fail the validation. the second example works the exact same way except will use the custom message instead of default.
if the object syntax (2) is used, and the user does not define a
validate
property or thevalidate
property is not a function, the validator will not invoke the callback and the validation will pass.