Performs validation on fields while triggering events.
@returns true
if all validations succeeds, false
if a failure is immediately detected, or null
if dependant on a promise.
Consider using whenValidate
instead.
validate: function (options) {
if (arguments.length >= 1 && !$.isPlainObject(options)) {
Utils.warnOnce('Calling validate on a parsley form without passing arguments as an object is deprecated.');
var [group, force, event] = arguments;
options = {group, force, event};
}
return statusMapping[ this.whenValidate(options).state() ];
},
whenValidate: function ({group, force, event} = {}) {
this.submitEvent = event;
if (event) {
this.submitEvent = Object.assign({}, event, {preventDefault: () => {
Utils.warnOnce("Using `this.submitEvent.preventDefault()` is deprecated; instead, call `this.validationResult = false`");
this.validationResult = false;
}});
}
this.validationResult = true;