Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
Merge e8abae4 into c22d5a7
Browse files Browse the repository at this point in the history
  • Loading branch information
AzOoDev committed Jul 17, 2018
2 parents c22d5a7 + e8abae4 commit 101b69a
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,14 @@ Fz.Field.ValidationService = (function () {
/**
* Internal recursive function to validate the field.
*
* @param {Object} validationRules The validation rules which are checked.
* @param {Array} validationRulesKeys Keys of the remaining validation rules to check (used for recursive behaviour).
* @param {Object} validationRules The validation rules which are checked.
* @param {Array} validationRulesKeys Keys of the remaining validation rules to check (used for recursive behaviour).
* @param {Formz.ResultInstance} result
*/
var launchValidation = function (validationRules, validationRulesKeys) {
var launchValidation = function (validationRules, validationRulesKeys, result) {
var validatorName = validationRulesKeys[0];
var validationRule = validationRules[validatorName];
var result = Fz.Result.get({defaultErrorMessage: defaultErrorMessage});
result = result || Fz.Result.get({defaultErrorMessage: defaultErrorMessage});
var finalValidationCallback = function () {
handleValidationResult(validatorName, result);
};
Expand All @@ -153,13 +154,13 @@ Fz.Field.ValidationService = (function () {
/** @type {validationResultCallback} */
var callback;

callback = function (result) {
if (false === result.hasErrors()
callback = function (freshResult) {
if (false === freshResult.hasErrors()
&& validationRulesKeys.length > 1
) {
// Handling the remaining rules.
validationRulesKeys.splice(0, 1);
launchValidation(validationRules, validationRulesKeys);
launchValidation(validationRules, validationRulesKeys, result);
} else {
// The result has errors, or no more rule to check: the checks stop and the result is handled.
finalValidationCallback();
Expand All @@ -186,7 +187,7 @@ Fz.Field.ValidationService = (function () {
if (validationRulesKeys.length > 1) {
// Handling the remaining rules.
validationRulesKeys.splice(0, 1);
launchValidation(validationRules, validationRulesKeys);
launchValidation(validationRules, validationRulesKeys, result);
} else {
// No more rule to check: the checks stop.
finalValidationCallback();
Expand Down

0 comments on commit 101b69a

Please sign in to comment.