Validatinator.utils.convertFieldValidationsToArray(Object validationInformation);

Convert string field validations to array field validations.
"required|min:5|max:10" => ["required", "min:5", "max:10"];

@Added: 12/16/2013
760480
function(validationInformation) {
        var fieldValidation;

        // Loop through the top level forms.
        for (var formName in validationInformation) {
            // Loop through each, individual, field that has validation tests attached to it.
            for (var fieldName in validationInformation[formName]) {
                // Get the current field's validation string.
                fieldValidation = validationInformation[formName][fieldName];

                // Go ahead and create a nicely formated array of each field validation; if there is only a single field validation then
                // we will use an array literal to create our array ourselves.
                validationInformation[formName][fieldName] = (fieldValidation.contains("|")) ? fieldValidation.split("|") : [fieldValidation];
            }
        }

        return validationInformation;
    }
139063
def field2length(self, field, **kwargs):
        
        attributes = {}

        validators = [
            validator
            for validator in field.validators
            if (
                hasattr(validator, "min")
                and hasattr(validator, "max")
                and hasattr(validator, "equal")
            )
        ]

        is_array = isinstance(
            field, (marshmallow.fields.Nested, marshmallow.fields.List)
        )
        min_attr = "minItems" if is_array else "minLength"
        max_attr = "maxItems" if is_array else "maxLength"

        for validator in validators:
            if validator.min is not None:
                if hasattr(attributes, min_attr):
                    attributes[min_attr] = max(attributes[min_attr], validator.min)
                else:
                    attributes[min_attr] = validator.min
            if validator.max is not None:
                if hasattr(attributes, max_attr):
                    attributes[max_attr] = min(attributes[max_attr], validator.max)
                else:
                    attributes[max_attr] = validator.max

        for validator in validators:
            if validator.equal is not None:
                attributes[min_attr] = validator.equal
                attributes[max_attr] = validator.equal
        return attributes
209496
function (element) {
            // Begin with checking the validate
            var elementAsArray = [ element ],
                validationType = element.getAttribute("data-validate") || null;
                invalidElement = [];
            if (validationType !== null) {
                validationType = this.splitStringByComma(validationType);
                for (var i = 0; i < validationType.length; i++) {
                    invalidElement = this.getElementsByPattern(elementAsArray, this.patterns[validationType[i]], validationType[i]);
                    if (invalidElement.length > 0) {
                        this.currentValidationType = validationType[i];
                        return false;
                    }
                }
            }
            // As data-validate="length" has already been checked,
            // only check the elements with data-length set.
            if (element.getAttribute("data-length") === null ||
                validationType !== null && validationType.indexOf("length") !== -1)
                return true;
            validationType = "length";
            invalidElement = this.getElementsByPattern(elementAsArray, this.patterns[validationType], validationType);
            if (invalidElement.length > 0)
                return false;

            return true;
        }
68176
@Override
    public void validate() throws Exception {
        super.validate();
        this.parse();
        Assert.assertTrue(
                String.format(
                        "Lower bound %d should be less than upper bound %d",
                        lower,
                        upper),
                lower <= upper);
        Assert.assertFalse(
                "The range is empty",
                !this.includeLower
                    && !this.includeUpper
                    && (this.upper - this.lower) <= 1);
        Assert.assertFalse(
                "The range is empty",
                !(this.includeLower && this.includeUpper)
                    && (this.upper - this.lower) < 1);
    }
195933
private void validateKeyTypes(int[] keyFieldIndices) {
		final TypeInformation<?>[] types = getFieldTypes();
		for (int keyFieldIndex : keyFieldIndices) {
			final TypeInformation<?> type = types[keyFieldIndex];
			if (!TypeCheckUtils.isSimpleStringRepresentation(type)) {
				throw new ValidationException(
					"Only simple types that can be safely converted into a string representation " +
						"can be used as keys. But was: " + type);
			}
		}
	}
697427
@SuppressWarnings("unchecked")
	private static ValidationFail performFieldValidations(Context context, FieldInfo fieldInfo, View view) {
		// first, we need to check if condition is not applied for all validations on field
		if (fieldInfo.condition != null && fieldInfo.condition.validationAnnotation().equals(Condition.class)) {
			// condition is applied to all validations on field
			boolean evaluation = evaluateCondition(view, fieldInfo.condition);
			if (! evaluation) {
				// go to next field
				return null;
			}
		}

		// field validations
		for (ValidationInfo valInfo : fieldInfo.validationInfoList) {
			final Annotation annotation = valInfo.annotation;
			if (fieldInfo.condition != null && fieldInfo.condition.validationAnnotation().equals(annotation.annotationType())) {
				boolean evaluation = evaluateCondition(view, fieldInfo.condition);

				if (! evaluation) {
					// continue to next annotation
					continue;
				}
			}
			final IFieldAdapter adapter = FieldAdapterFactory.getAdapterForField(view, annotation);
			if (adapter == null) {
				throw new NoFieldAdapterException(view, annotation);
			}

			final Object value = adapter.getFieldValue(annotation, view);
			final boolean isValid = valInfo.validator.validate(annotation, value);

			if (! isValid) {
				final String message = valInfo.validator.getMessage(context, annotation, value);
				final int order = valInfo.validator.getOrder(annotation);

				// no more validations on this field
				return new ValidationFail(view, message, order);
			}
		}
		return null;
	}
757443
private boolean validateMinValue(Object validationObject, Annotation annotate)
    {
        if (checkNullObject(validationObject))
        {
            return true;
        }

        Long minValue = ((Min) annotate).value();
        if (checkvalidDigitTypes(validationObject.getClass()))
        {
            if ((NumberUtils.toLong(toString(validationObject))) < minValue)
            {

                throwValidationException(((Min) annotate).message());
            }
        }

        return true;
    }
359298
private int[] getRange(String field, int min, int max) {
        int[] result = new int[2];
        if (field.contains("*")) {
            result[0] = min;
            result[1] = max - 1;
            return result;
        }
        if (!field.contains("-")) {
            result[0] = result[1] = Integer.valueOf(field);
        } else {
            String[] split = StringUtils.delimitedListToStringArray(field, "-");
            if (split.length > 2) {
                throw new IllegalArgumentException("Range has more than two fields: '" + field + "' in expression \""
                        + this.expression + "\"");
            }
            result[0] = Integer.valueOf(split[0]);
            result[1] = Integer.valueOf(split[1]);
        }
        if (result[0] >= max || result[1] >= max) {
            throw new IllegalArgumentException("Range exceeds maximum (" + max + "): '" + field + "' in expression \""
                    + this.expression + "\"");
        }
        if (result[0] < min || result[1] < min) {
            throw new IllegalArgumentException("Range less than minimum (" + min + "): '" + field
                    + "' in expression \"" + this.expression + "\"");
        }
        return result;
    }
1288775
@Override
    public String validate(DTDValidatorBase v, char[] cbuf, int start, int end, boolean normalize)
        throws XMLStreamException
    {
        int origLen = end-start;

        // Let's trim leading white space first...
        while (start < end && WstxInputData.isSpaceChar(cbuf[start])) {
            ++start;
        }

        // Empty value?
        if (start >= end) {
            return reportValidationProblem(v, "Empty NMTOKEN value");
        }

        --end; // so that it now points to the last char
        while (end > start && WstxInputData.isSpaceChar(cbuf[end])) {
            --end;
        }

        // Ok, need to check char validity
        for (int i = start; i <= end; ++i) {
            char c = cbuf[i];
            if (!WstxInputData.isNameChar(c, mCfgNsAware, mCfgXml11)) {
                return reportInvalidChar(v, c, "not valid NMTOKEN character");
            }
        }

        if (normalize) {
            // Let's only create the String if we trimmed something
            int len = (end - start)+1;
            if (len != origLen) {
                return new String(cbuf, start, len);
            }
        }
        return null;
    }
328261
@SuppressWarnings("cast")
    @Override
    public String validate(DTDValidatorBase v, char[] cbuf, int start, int end, boolean normalize)
        throws XMLStreamException
    {
        /* Let's skip leading/trailing white space, even if we are not
         * to normalize visible attribute value. This allows for better
         * round-trip handling (no changes for physical value caller
         * gets), but still allows succesful validation.
         */
        while (start < end && WstxInputData.isSpaceChar(cbuf[start])) {
            ++start;
        }

        // No id?
        if (start >= end) {
            return reportValidationProblem(v, "Empty IDREFS value");
        }

        --end; // so that it now points to the last char
        // We now the first char is not a space by now...
        while (end > start && WstxInputData.isSpaceChar(cbuf[end])) {
            --end;
        }

        // Ok; now start points to first, end to last char (both inclusive)
        ElementIdMap m = v.getIdMap();
        Location loc = v.getLocation();

        String idStr = null;
        StringBuilder sb = null;
        while (start <= end) {
            // Ok, need to check char validity, and also calc hash code:
            char c = cbuf[start];
            if (!WstxInputData.isNameStartChar(c, mCfgNsAware, mCfgXml11)) {
                return reportInvalidChar(v, c, "not valid as the first IDREFS character");
            }
            int hash = (int) c;
            int i = start+1;
            for (; i <= end; ++i) {
                c = cbuf[i];
                if (WstxInputData.isSpaceChar(c)) {
                    break;
                }
                if (!WstxInputData.isNameChar(c, mCfgNsAware, mCfgXml11)) {
                    return reportInvalidChar(v, c, "not valid as an IDREFS character");
                }
                hash = (hash * 31) + (int) c;
            }

            // Ok, got the next id ref...
            ElementId id = m.addReferenced(cbuf, start, i - start, hash,
                                           loc, v.getElemName(), mName);
            
            // Can skip the trailing space char (if there was one)
            start = i+1;

            /* When normalizing, we can possibly share id String, or
             * alternatively, compose normalized String if multiple
             */
            if (normalize) {
                if (idStr == null) { // first idref
                    idStr = id.getId();
                } else {
                    if (sb == null) {
                        sb = new StringBuilder(idStr);
                    }
                    idStr = id.getId();
                    sb.append(' ');
                    sb.append(idStr);
                }
            }

            // Ok, any white space to skip?
            while (start <= end && WstxInputData.isSpaceChar(cbuf[start])) {
                ++start;
            }
        }

        if (normalize) {
            if (sb != null) {
                idStr = sb.toString();
            }
            return idStr;
        }

        return null;
    }
343276
public List<ValidationError> validateInput() {
        List<ValidationError> errors = new ArrayList<ValidationError>();

        for (FormSectionController section : getSections()) {
            for (FormElementController element : section.getElements()) {
                if (element instanceof LabeledFieldController) {
                    LabeledFieldController field = (LabeledFieldController)element;
                    errors.addAll(field.validateInput());
                }
            }
        }

        return errors;
    }
834138
public List<String> toList() {

        List<String> errorStrings = new ArrayList<String>();
        ErrorIterator errIterator = iterator();
        while (errIterator.hasNext()) {
            ValidationError err = errIterator.next();
            errorStrings.add(err.getMessage());
        }
        return errorStrings;
    }
414761
function() {
            const messages = [];
            if (this.validationMessages && this.validationMessages.errors) {
              const l = this.validationMessages.errors.length;
              var i = 0;
              for (i = 0; i < l; i++) {
                messages.push(this.validationMessages.errors[i].message + " from " + this.validationMessages.errors[i].dataPath);
              }
            }
            return messages;
          }
359316
function(field, length) {
    if (Array.isArray(field)) {
      return this.validateFieldsHelper(field, [length], this.validatesLengthOf)
    }

    return this.validates(field, function() {
      var valid = true
      if (this[field]) valid = this[field].length <= length
      if (!valid)
        this.errors.add(field, 'maximum length of ' + length + ' exceeded')
      return valid
    })
  }
297360
@SuppressWarnings("unchecked")
	@Override
	protected void performValidation(String path, Object value, List<ValidationResult> results) {
		String name = path != null ? path : "value";
		value = ObjectReader.getValue(value);

		super.performValidation(path, value, results);

		if (value == null)
			return;

		if (value instanceof List<?>) {
			List<Object> list = (List<Object>) value;
			int index = 0;
			for (Object element : list) {
				String elementPath = path == null || path.length() == 0 ? Integer.toString(index) : path + "." + index;
				performTypeValidation(elementPath, _valueType, element, results);
				index++;
			}
		} else if (value.getClass().isArray()) {
			int length = Array.getLength(value);
			for (int index = 0; index < length; index++) {
				Object element = Array.get(value, index);
				String elementPath = path == null || path.length() == 0 ? Integer.toString(index) : path + "." + index;
				performTypeValidation(elementPath, _valueType, element, results);
				index++;
			}
		} else {
			results.add(new ValidationResult(path, ValidationResultType.Error, "VALUE_ISNOT_ARRAY",
					name + " type must be List or Array", "List", value.getClass()));
		}
	}
137567
public boolean validateAllFields() {
        boolean cardNumberIsValid =
                CardUtils.isValidCardNumber(mCardNumberEditText.getCardNumber());
        boolean expiryIsValid = mExpiryDateEditText.getValidDateFields() != null &&
                mExpiryDateEditText.isDateValid();
        boolean cvcIsValid = isCvcLengthValid();
        mCardNumberEditText.setShouldShowError(!cardNumberIsValid);
        mExpiryDateEditText.setShouldShowError(!expiryIsValid);
        mCvcEditText.setShouldShowError(!cvcIsValid);
        boolean postalCodeIsValidOrGone;
        if (mShouldShowPostalCode) {
            postalCodeIsValidOrGone = isPostalCodeMaximalLength(true,
                    mPostalCodeEditText.getText().toString());
            mPostalCodeEditText.setShouldShowError(!postalCodeIsValidOrGone);
        } else {
            postalCodeIsValidOrGone = true;
        }

        return cardNumberIsValid
                && expiryIsValid
                && cvcIsValid
                && postalCodeIsValidOrGone;
    }
788973
public List<ValidationResult> validate(Object value) {
		List<ValidationResult> results = new ArrayList<ValidationResult>();
		performValidation("", value, results);
		return results;
	}