Validator for the "type" form field property
198050
public function validateType(string $key, array $def, $value)
    {
        if (isset($def['type']) && $value != '') {
            switch ($def['type']) {
                case 'int':
                    if (!is_int($value) && !preg_match('/^\d+$/', $value)) {
                        $this->addError($key, 'form.value_type_integer');
                    }
                    break;
                case 'numeric':
                    if (!is_numeric($value)) {
                        $this->addError($key, 'form.value_type_numeric');
                    }
                    break;
                case 'scalar':
                    if (!is_scalar($value)) {
                        $this->addError($key, 'form.value_type_scalar');
                    }
                    break;
                case 'list':
                    if (!is_array($value)) {
                        $this->addError($key, 'form.value_type_list');
                    }
                    break;
                case 'float':
                    if (isset($def['type_params'])) {
                        if (!is_array($def['type_params'])) {
                            throw new Exception('type_params must be an array and contain the key "decimal"');
                        }
                        $options = $def['type_params'];
                    } else {
                        $options = array('decimal' => $this->translate('form.decimal_point'));
                    }
                    if (!filter_var($value, FILTER_VALIDATE_FLOAT, array('options' => $options))) {
                        $this->addError($key, 'form.value_type_float');
                    }
                    break;
                case 'bool':
                    if (!is_bool($value)) {
                        $this->addError($key, 'form.value_type_bool');
                    }
                    break;
                case 'string':
                    if (!is_string($value)) {
                        $this->addError($key, 'form.value_type_string');
                    }
                    break;
                case 'email':
                    if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
                        $this->addError($key, 'form.value_type_email');
                    }
                    break;
                case 'ip':
                    if (!filter_var($value, FILTER_VALIDATE_IP)) {
                        $this->addError($key, 'form.value_type_ip');
                    }
                    break;
                case 'url':
                    if (!filter_var($value, FILTER_VALIDATE_URL)) {
                        $this->addError($key, 'form.value_type_url');
                    }
                    break;
                case 'date':
                case 'time':
                case 'datetime':
                    if (!is_object($value) && DateTime::createFromFormat($this->translate('form.' . $def['type']), $value) === false) {
                        $this->addError($key, 'form.value_type_' . $def['type']);
                    }
                    break;
                case 'switch':
                    if ($value != '' && $value != 1 && $value != 0) {
                        $this->addError($key, 'form.value_type_switch');
                    }
                    break;
                default:
                    throw new Exception('Invalid field type: ' . $def['type']);
                    break;
            }
        }
    }
1140263
function validateFields ( fldsMeta, fldsValue ) {
        return reduce(function ( acc, fldMeta, fldID ) {
            var value  = getOrNull( fldsValue, fldID )
              , errors = validateField( fldID, fldMeta, value );
            return t.merge( acc, errors );
        }, {}, fldsMeta );
    }
111878
function validate($value, $key, $fields, $options, $exists, \CharlotteDunois\Validation\Validator $validator) {
        if(isset($_FILES[$key])) {
            if(!\file_exists($_FILES[$key]['tmp_name'])) {
                return 'formvalidator_make_image';
            }
            
            $size = \getimagesize($_FILES[$key]['tmp_name']);
        } else {
            if(!$exists) {
                return false;
            }
            
            $size = @\getimagesizefromstring($value);
        }
        
        if(!$size) {
            return 'formvalidator_make_image';
        }
        
        return true;
    }
1016029
function ( type, text, numericalValue ) {
		var content = THREE.LoaderSupport.Validator.isValid( text ) ? text: '';
		var event = {
			detail: {
				type: type,
				modelName: this.modelName,
				instanceNo: this.instanceNo,
				text: content,
				numericalValue: numericalValue
			}
		};

		if ( THREE.LoaderSupport.Validator.isValid( this.callbacks.onProgress ) ) this.callbacks.onProgress( event );

		if ( this.logging.enabled && this.logging.debug ) console.debug( content );
	}
244882
function validate($value, $key, $fields, $options, $exists, \CharlotteDunois\Validation\Validator $validator) {
        if(!$exists) {
            return false;
        }
        
        if(!\is_array($value)) {
            return 'formvalidator_make_array';
        }
        
        if(!empty($options)) {
            foreach($value as $val) {
                $type = \gettype($val);
                if($type === 'double') {
                    $type = 'float'; // @codeCoverageIgnore
                }
                
                if($type !== $options) {
                    return array('formvalidator_make_array_subtype', array('{0}' => $options));
                }
            }
        }
        
        return true;
    }
1309413
function Validator(config) {
  
  // Instance properties
  this.rules = {};
  this.rulesCount = 0;
  this.messages = {};
  this.optional = [];
  this.filters = {};
  this.postFilters = {};
  this.postValidations = [];
  
  // Options
  this.config = protos.extend({
    cleanup: true
  }, config || {});
  
  // Set context
  Object.defineProperty(this, '__context', {
    value: {},
    writable: true,
    enumerable: false,
    configurable: false
  });

  // App property
  Object.defineProperty(this, 'app', {
    value: protos.app,
    writable: true,
    enumerable: false,
    configurable: false
  });
  
}
812121
function validate(schema) {
        var key, item;
        for (key in schema) {
            if (schema.hasOwnProperty(key)) {
                item = schema[key];
                if (!item.text) {
                    console.error("[PreferenceManager] missing required field: 'text' of '" + key + "'");
                }
                if (!item.type) {
                    console.error("[PreferenceManager] missing required field: 'type' of '" + key + "'");
                }
                if (item.type !== "Section" && typeof item['default'] === "undefined") {
                    console.error("[PreferenceManager] missing required field: 'default' of '" + key + "'");
                }
                if (item.type === "Combo" || item.type === "Dropdown") {
                    if (item.options && item.options.length > 0) {
                        var i, len;
                        for (i = 0, len = item.options.length; i < len; i++) {
                            if (typeof item.options[i].value === "undefined") {
                                console.error("[PreferenceManager] missing required field of option item: 'value' of '" + key + "'");
                            }
                            if (typeof item.options[i].text === "undefined") {
                                console.error("[PreferenceManager] missing required field of option item: 'text' of '" + key + "'");
                            }
                        }
                    } else {
                        console.error("[PreferenceManager] missing required field or no items: 'options' of '" + key + "'");
                    }
                }
            }
        }
        return true;
    }
1096169
def _determine_validator_type(self, data_type, value, has_default):
        """"""
        data_type, nullable = unwrap_nullable(data_type)

        validator = None

        if is_list_type(data_type):
            item_validator = self._determine_validator_type(
                data_type.data_type, value, False)
            item_validator = item_validator if item_validator else 'nil'

            validator = '{}:{}'.format(
                fmt_validator(data_type),
                fmt_func_args([
                    ('minItems', '@({})'.format(data_type.min_items)
                     if data_type.min_items else 'nil'),
                    ('maxItems', '@({})'.format(data_type.max_items)
                     if data_type.max_items else 'nil'),
                    ('itemValidator', item_validator),
                ]))
        elif is_map_type(data_type):
            item_validator = self._determine_validator_type(
                data_type.value_data_type, value, False)
            item_validator = item_validator if item_validator else 'nil'

            validator = '{}:{}'.format(
                fmt_validator(data_type),
                fmt_func_args([
                    ('itemValidator', item_validator),
                ]))
        elif is_numeric_type(data_type):
            if data_type.min_value or data_type.max_value:
                validator = '{}:{}'.format(
                    fmt_validator(data_type),
                    fmt_func_args([
                        ('minValue', '@({})'.format(data_type.min_value)
                         if data_type.min_value else 'nil'),
                        ('maxValue', '@({})'.format(data_type.max_value)
                         if data_type.max_value else 'nil'),
                    ]))
        elif is_string_type(data_type):
            if data_type.pattern or data_type.min_length or data_type.max_length:
                pattern = data_type.pattern.encode('unicode_escape').replace(
                    "\"", "\\\"") if data_type.pattern else None
                validator = '{}:{}'.format(
                    fmt_validator(data_type),
                    fmt_func_args([
                        ('minLength', '@({})'.format(data_type.min_length)
                         if data_type.min_length else 'nil'),
                        ('maxLength', '@({})'.format(data_type.max_length)
                         if data_type.max_length else 'nil'),
                        ('pattern', '@"{}"'.format(pattern)
                         if pattern else 'nil'),
                    ]))

        if nullable:
            if validator:
                validator = fmt_func_call(
                    caller='DBStoneValidators', callee=validator)
                validator = fmt_func_call(
                    caller='DBStoneValidators',
                    callee='nullableValidator',
                    args=validator)
        else:
            if validator:
                validator = fmt_func_call(
                    caller='DBStoneValidators', callee=validator)
            else:
                validator = 'nil'
            if not has_default:
                validator = fmt_func_call(
                    caller='DBStoneValidators',
                    callee='nonnullValidator',
                    args=validator)
            else:
                validator = None
        return validator
85371
def validate_is_document_type(option, value):
    """"""
    if not isinstance(value, (abc.MutableMapping, RawBSONDocument)):
        raise TypeError("%s must be an instance of dict, bson.son.SON, "
                        "bson.raw_bson.RawBSONDocument, or "
                        "a type that inherits from "
                        "collections.MutableMapping" % (option,))
1124617
function typecast(value, originalValue, properties) {
        const options = this[_privateKey]._options;

        // Allow transform to manipulate raw properties.
        if (properties.transform) {
            value = properties.transform.call(this[_privateKey]._root, value, originalValue, properties);
        }

        // Allow null to be preserved.
        if (value === null && options.preserveNull) {
            return null;
        }

        // Helper function designed to detect and handle usage of array-form custom error messages for validators
        function detectCustomErrorMessage(key) {
            if (typeof properties[key] === 'object' && properties[key].errorMessage && properties[key].value) {
                return properties[key];
            }
            else  if (_.isArray(properties[key])) {
                return {
                    value: properties[key][0],
                    errorMessage: properties[key][1]
                };
            }
            else {
                return {
                    value: properties[key],
                    errorMessage: undefined
                };
            }
        }

        // Property types are always normalized as lowercase strings despite shorthand definitions being available.
        switch (properties.type) {
            case 'string':
                // Reject if object or array.
                if (_.isObject(value) || _.isArray(value)) {
                    throw new StringCastError(value, originalValue, properties);
                }

                // If index is being set with null or undefined, set value and end.
                if (value === undefined || value === null) {
                    return undefined;
                }

                // Typecast to String.
                value = value + '';

                // If stringTransform function is defined, use.
                // This is used before we do validation checks (except to be sure we have a string at all).
                if (properties.stringTransform) {
                    value = properties.stringTransform.call(this[_privateKey]._root, value, originalValue, properties);
                }

                // If clip property & maxLength properties are set, the string should be clipped.
                // This is basically a shortcut property that could be done with stringTransform.
                if (properties.clip !== undefined && properties.maxLength !== undefined) {
                    value = value.substr(0, properties.maxLength);
                }

                let enumValidation;

                // Detect custom error message usage for enum (can't use function here as enum is expected to be an array)
                if (typeof properties.enum === 'object' && properties.enum.errorMessage && properties.enum.value) {
                    enumValidation = properties.enum;
                }
                else if (_.isArray(properties.enum) && _.isArray(properties.enum[0])) {
                    enumValidation = {
                        value: properties.enum[0],
                        errorMessage: properties.enum[1]
                    };
                }
                else {
                    enumValidation = {
                        value: properties.enum,
                        errorMessage: undefined
                    };
                }

                // If enum is being used, be sure the value is within definition.
                if (
                    enumValidation.value !== undefined &&
                    _.isArray(enumValidation.value) &&
                    enumValidation.value.indexOf(value) === -1
                ) {
                    throw new StringEnumValidationError(enumValidation.errorMessage, value, originalValue, properties);
                }

                // Detect custom error message usage for minLength
                let minLength = detectCustomErrorMessage('minLength');

                // If minLength is defined, check to be sure the string is > minLength.
                if (minLength.value !== undefined && value.length < minLength.value) {
                    throw new StringMinLengthValidationError(minLength.errorMessage, value, originalValue, properties);
                }

                // Detect custom error message usage for maxLength
                let maxLength = detectCustomErrorMessage('maxLength');

                // If maxLength is defined, check to be sure the string is < maxLength.
                if (maxLength.value !== undefined && value.length > maxLength.value) {
                    throw new StringMaxLengthValidationError(maxLength.errorMessage, value, originalValue, properties);
                }

                // Detect custom error message usage for maxLength
                let regex = detectCustomErrorMessage('regex');

                // If regex is defined, check to be sure the string matches the regex pattern.
                if (regex.value && !regex.value.test(value)) {
                    throw new StringRegexValidationError(regex.errorMessage, value, originalValue, properties);
                }

                return value;

            case 'number':
                // If index is being set with null, undefined, or empty string: clear value.
                if (value === undefined || value === null || value === '') {
                    return undefined;
                }

                // Set values for boolean.
                if (_.isBoolean(value)) {
                    value = value ? 1 : 0;
                }

                // Remove/convert number group separators
                if (typeof value === 'string') {
                    if (options.useDecimalNumberGroupSeparator) {
                        // Remove decimals
                        value = value.replace(/\./g, '');
                        // Replace commas with decimals for js parsing
                        value = value.replace(/,/g, '.');
                    }
                    else {
                        //Remove commas
                        value = value.replace(/,/g, '');
                    }

                    // Reject if string was not a valid number
                    if (isNaN(Number(value))) {
                      throw new NumberCastError('String', value, originalValue, properties);
                    }
                }

                // Reject if array, object, or not numeric.
                if (_.isArray(value)) {
                    throw new NumberCastError('Array', value, originalValue, properties);
                }
                else if (_.isObject(value)) {
                    throw new NumberCastError('Object', value, originalValue, properties);
                }
                else if (!isNumeric(value)) {
                    throw new NumberCastError('Non-numeric', value, originalValue, properties);
                }

                // Typecast to number.
                value = Number(value);

                // Transformation after typecasting but before validation and filters.
                if (properties.numberTransform) {
                    value = properties.numberTransform.call(this[_privateKey]._root, value, originalValue, properties);
                }

                // Detect custom error message usage for min
                let min = detectCustomErrorMessage('min');

                if (min.value !== undefined && value < min.value) {
                    throw new NumberMinValidationError(min.errorMessage, value, originalValue, properties);
                }

                // Detect custom error message usage for min
                let max = detectCustomErrorMessage('max');

                if (max.value !== undefined && value > max.value) {
                    throw new NumberMaxValidationError(max.errorMessage, value, originalValue, properties);
                }

                return value;

            case 'boolean':
                // If index is being set with null, undefined, or empty string: clear value.
                if (value === undefined || value === null || value === '') {
                    return undefined;
                }

                // If is String and is 'false', convert to Boolean.
                if (value === 'false') {
                    return false;
                }

                // If is Number, <0 is true and >0 is false.
                if (isNumeric(value)) {
                    return (value * 1) > 0;
                }

                // Use Javascript to eval and return boolean.
                value = !!value;

                // Transformation after typecasting but before validation and filters.
                if (properties.booleanTransform) {
                    value = properties.booleanTransform.call(this[_privateKey]._root, value, originalValue, properties);
                }

                return value;

            case 'array':
                // If it's an object, typecast to an array and return array.
                if (_.isObject(value)) {
                    value = _.toArray(value);
                }

                // Reject if not array.
                if (!_.isArray(value)) {
                    throw new ArrayCastError(value, originalValue, properties);
                }

                // Arrays are never set directly.
                // Instead, the values are copied over to the existing SchemaArray instance.
                // The SchemaArray is initialized immediately and will always exist.
                originalValue.length = 0;
                _.each(value, (arrayValue) => {
                    originalValue.push(arrayValue);
                });

                return originalValue;

            case 'object':
                // If it's not an Object, reject.
                if (!_.isObject(value)) {
                    throw new ObjectCastError(value, originalValue, properties);
                }

                // If object is schema object and an entirely new object was passed, clear values and set.
                // This preserves the object instance.
                if (properties.objectType) {
                    // The object will usually exist because it's initialized immediately for deep access within SchemaObjects.
                    // However, in the case of Array elements, it will not exist.
                    let schemaObject;
                    if (originalValue !== undefined) {
                        // Clear existing values.
                        schemaObject = originalValue;
                        schemaObject.clear();
                    } else {
                        // The SchemaObject doesn't exist yet. Let's initialize a new one.
                        // This is used for Array types.
                        schemaObject = new properties.objectType({}, this[_privateKey]._root);
                    }

                    // Copy value to SchemaObject and set value to SchemaObject.
                    for (const key in value) {
                        schemaObject[key] = value[key];
                    }
                    value = schemaObject;
                }

                // Otherwise, it's OK.
                return value;

            case 'date':
                // If index is being set with null, undefined, or empty string: clear value.
                if (value === undefined || value === null || value === '') {
                    return undefined;
                }

                // Reject if object, array or boolean.
                if (!_.isDate(value) && !_.isString(value) && !_.isNumber(value)) {
                    throw new DateCastError(value, originalValue, properties);
                }

                // Attempt to parse string value with Date.parse (which returns number of milliseconds).
                if (_.isString(value)) {
                    value = Date.parse(value);
                }

                // If is timestamp, convert to Date.
                if (isNumeric(value)) {
                    value = new Date((value + '').length > 10 ? value : value * 1000);
                }

                // If the date couldn't be parsed, do not modify index.
                if (value == 'Invalid Date' || !_.isDate(value)) {
                    throw new DateParseValidationError(null, value, originalValue, properties);
                }

                // Transformation after typecasting but before validation and filters.
                if (properties.dateTransform) {
                    value = properties.dateTransform.call(this[_privateKey]._root, value, originalValue, properties);
                }

                return value;

            default: // 'any'
                return value;
        }
    }
705463
function validate (schema, data, key) {
  let value = data[key]
  const bool = value == null || value === ''
  const { required, type, validate, transform, elements } = schema
  const def = schema['default']
  // trigger error if undefined but required
  if (required && bool) throw new Error(`field ${key} is missing`)
  // coerce to type
  if (type && !bool) {
    let before = coerce(type, key, value)
    data[key] = elements
      ? (type === 'object' ? validator(before, elements) : before.map(item => validator(item, elements)))
      : before
  }
  // validate value
  if (validate) {
    const cb = check(validate, key)
    if (type === 'array') value.map(cb)
    else cb(value)
  }
  // apply default value
  if (def && bool) data[key] = def
  // apply transform
  if (transform && def == null) {
    data[key] = typeof transform === 'function'
      ? (type === 'array' ? value.map(transform) : transform(value))
      : transform
  }
}
340998
def validate(self):
        

        missing = self.missing_property_names()

        if len(missing) > 0:
            raise validators.ValidationError(
                "'{0}' are required attributes for {1}"
                            .format(missing, self.__class__.__name__))

        for prop, val in six.iteritems(self._properties):
            if val is None:
                continue

            if isinstance(val, ProtocolBase):
                val.validate()
            elif getattr(val, 'isLiteralClass', None) is True:
                val.validate()
            elif isinstance(val, list):
                for subval in val:
                  subval.validate()
            else:
                # This object is of the wrong type, but just try setting it
                # The property setter will enforce its correctness
                # and handily coerce its type at the same time
                setattr(self, prop, val)

        return True
130279
function validatePropTypes(element) {
  var componentClass = element.type;
  if (typeof componentClass !== 'function') {
    return;
  }
  var name = componentClass.displayName || componentClass.name;
  var propTypes = componentClass.propTypes;

  if (propTypes) {
    currentlyValidatingElement = element;
    checkPropTypes$1(propTypes, element.props, 'prop', name, getStackAddendum$1);
    currentlyValidatingElement = null;
  }
  if (typeof componentClass.getDefaultProps === 'function') {
    warning$3(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
  }
}
952980
function(){
		var matches, matchesOverride;
		var exp = $.expr[":"];
		var rElementsGroup = /^(?:form|fieldset)$/i;
		var hasInvalid = function(elem){
			var ret = false;
			$(elem).jProp('elements').each(function(){
				if(!rElementsGroup.test(this.nodeName || '')){
					ret = exp.invalid(this);
					if(ret){
						return false;
					}
				}

			});
			return ret;
		};
		$.extend(exp, {
			"valid-element": function(elem){
				return rElementsGroup.test(elem.nodeName || '') ? !hasInvalid(elem) : !!($.prop(elem, 'willValidate') && isValid(elem));
			},
			"invalid-element": function(elem){
				return rElementsGroup.test(elem.nodeName || '') ? hasInvalid(elem) : !!($.prop(elem, 'willValidate') && !isValid(elem));
			},
			"required-element": function(elem){
				return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required'));
			},
			"user-error": function(elem){
				return ($.prop(elem, 'willValidate') && $(elem).getShadowElement().hasClass((options.iVal.errorClass || 'user-error')));
			},
			"optional-element": function(elem){
				return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required') === false);
			}
		});
		
		['valid', 'invalid', 'required', 'optional'].forEach(function(name){
			exp[name] = $.expr[":"][name+"-element"];
		});
		
		// sizzle/jQuery has a bug with :disabled/:enabled selectors
		if(support.fieldsetdisabled && !$('<fieldset disabled=""><input /><input /></fieldset>').find(':disabled').filter(':disabled').is(':disabled')){
			matches = $.find.matches;
			matchesOverride = {':disabled': 1, ':enabled': 1};
			$.find.matches = function(expr, elements){
				if(matchesOverride[expr]){
					return matches.call(this, '*'+expr, elements);
				}
				return matches.apply(this, arguments);
			};
			$.extend(exp, {
				"enabled": function( elem ) {
					return 'disabled' in elem && elem.disabled === false && !$.find.matchesSelector(elem, 'fieldset[disabled] *');
				},
		
				"disabled": function( elem ) {
					return elem.disabled === true || ('disabled' in elem && $.find.matchesSelector(elem, 'fieldset[disabled] *'));
				}
			});
		}
		
		
		//bug was partially fixed in 1.10.0 for IE9, but not IE8 (move to es5 as soon as 1.10.2 is used)
		if(typeof document.activeElement == 'unknown'){
			var pseudoFocus = exp.focus;
			exp.focus = function(){
				try {
					return pseudoFocus.apply(this, arguments);
				} catch(e){
					webshims.error(e);
				}
				return false;
			};
		}
	}
579330
def validate(self, form_cls, obj=None):
        ''''''
        if 'application/json' not in request.headers.get('Content-Type'):
            errors = {'Content-Type': 'expecting application/json'}
            self.abort(400, errors=errors)
        form = form_cls.from_json(request.json, obj=obj, instance=obj,
                                  csrf_enabled=False)
        if not form.validate():
            self.abort(400, errors=form.errors)
        return form
976020
public function validate($mInput, $oField)
    {
        $mInput = parent::validate($mInput, $oField);

        if (!is_numeric($mInput)) {
            throw new FieldTypeException('This field should be numeric.', 1);
        }

        return $mInput;
    }
330174
function validate (type, value) {
  const { t } = readType(type)
  if (value === undefined || value === null) return { require: true }

  switch (t) {
    case SOPHIA_TYPES.int:
      return isNaN(value) || ['boolean'].includes(typeof value)
    case SOPHIA_TYPES.bool:
      return typeof value !== 'boolean'
    case SOPHIA_TYPES.address:
      return !(value[2] === '_' && ['ak', 'ct'].includes(value.slice(0, 2)))
    default:
      return false
  }
}