Validate given values using given model
@param values
@param model
@param type
@returns {*}
@private
774135
function (values, model, type) {
        var deferred = Q.defer();
        var modelData = {data: model};

        ModelValidator.validate(values, modelData, function (err, data) {
            deferred.resolve({data: data, err: err, type: type});
        });
        return deferred.promise;
    }
346181
function validateCompoundWithType(attribute, values) {
		            for(var i in values) {
		                var value = values[i];
		                if(typeof(value) !== 'object') {
			                  errors.push([attribute + '-' + i, "not-an-object"]);
		                } else if(! value.type) {
			                  errors.push([attribute + '-' + i, "missing-type"]);
		                } else if(! value.value) { // empty values are not allowed.
			                  errors.push([attribute + '-' + i, "missing-value"]);
		                }
		            }
	          }
57025
function validator (data, schema) {
  const result = Object.assign({}, data)
  Object.keys(schema).map(key => {
    let value = schema[key]
    const type = typeof value
    if (type !== 'object') {
      value = {
        transform: value
      }
    }
    validate(value, result, key)
  })
  return result
}
674333
function validateTypeAmong(startPos, endPos, x, types) {
  /* Succeed if the type of x is in the list 'types' */
  for (let type of types) {
    if (joinTypes(x.type(), type) !== null) {
      return;
    }
  }
  /* Report error */
  fail(startPos, endPos,
    'expected-value-of-some-type-but-got', [
      types,
      x.type()
    ]
  );
}
826615
def validate(self, value, model_instance):
        """"""
        if isinstance(value, six.string_types):
            super(JSONField, self).validate(value, model_instance)
            try:
                json.loads(value)
            except Exception as err:
                raise ValidationError(str(err))
1111087
function validate(key, values) {
  if(this.arity > 0 && values.length !== this.arity) {
    throw new TypeDefError(
      util.format('bad arity for \'%s\', expected %s got %s',
        key, this.arity, values.length));
  }
  var types = Array.isArray(this.type) ? this.type : [this.type]
    , i
    , type
    , val
    , num
    , coerced = []
    , enumerable = false;

  for(i = 0;i < types.length;i++) {
    type = types[i];
    val = values[i];
    enumerable = Array.isArray(type);
    if(enumerable) {
      if(!~type.indexOf(val)) {
        throw new TypeDefError(
          util.format('enum error on key \'%s\', got \'%s\' expected one of %s',
            key, val, type.join(', ')));
      }
    }
    switch(type) {
      case ByteSize:
        val = ByteSize.parse(val);
        break;
      case Boolean:
        if(val !== YES && val !== NO) {
          throw new Error(
            util.format('argument must be \'%s\' or \'%s\'', YES, NO));
        }
        val = val === YES ? true : false;
        break;
      case String:
        // strings can be quoted
        val = val.replace(/^"/, '').replace(/"$/, '');
        break;
      case Number:
        num = parseInt(val);
        if(isNaN(num) || !/^-?[0-9]+$/.test(val)) {
          throw new TypeDefError(
            util.format('number expected for \'%s\', got %s', key, val));
        }
        val = num;
        break;
    }

    coerced[i] = val;
  }
  if(this.arity === 1 && !this.repeats) return coerced[0];
  return Array.isArray(this.type) ? coerced : coerced[0];
}
578286
function validateType(type, value) {
	var numberRegex;
	switch (type.toLowerCase()) {
		case 'integer':
		case 'int':
			numberRegex = new RegExp('^[-+]?[0-9]+$');
			if (numberRegex.test(value)) {
				return parseInt(value);
			}
			else {
				throw new InvalidInputError(value + " wasn't of type " + type);
			}
			break;
		case 'number':
		case 'float':
		case 'double':
			numberRegex = new RegExp('^[-+]?[0-9]*([\.,][0-9]+)?$');
			if (numberRegex.test(value)) {
				return parseFloat(value);
			}
			else {
				throw new InvalidInputError(value + " wasn't of type " + type);
			}
			break;
		case 'string':
			//Anything is a string
			return value;
		case 'path':
			// A path that may be relative or absolute. We should parse this into an absolute path
			if(path.isAbsolute(value)) {
				return path.normalize(value);
			}
			return path.resolve(process.cwd(), value);
		default:
			return value;
			break;
	}
}
727267
function validate(values) {
    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    var s = this;

    var _tv4$validateMultiple = tv4.validateMultiple(values, s),
        valid = _tv4$validateMultiple.valid,
        errors = _tv4$validateMultiple.errors;

    if (valid) {
      return null;
    }

    var assign = options.assign,
        _options$name = options.name,
        name = _options$name === void 0 ? 'SchemaError' : _options$name;
    var _s$schema = s.schema,
        schema = _s$schema === void 0 ? {} : _s$schema;
    var error = new Error("Validation failed with schema: ".concat(schema.title || schema.id || schema.description));
    return Object.assign(error, {
      id: uuid.v4(),
      name: name,
      errors: errors,
      schema: schema,
      values: values,
      engine: 'tv4'
    }, assign);
  }
1101139
def _validated(self, values):
        """"""
        if self.length != len(values):
            raise NotValid(
                "%r does not have exactly %d values. (Got %d.)" % (
                    values, self.length, len(values)))
        return type(self.schemas)(
            self.schemas[i].validate(v) for i, v in enumerate(values))
381673
def validate(self, model, validator=None):
    
    for filter_ in self.filters:
      if not filter_(model):
        return True

    is_valid, message = self.is_valid(model, validator)
    if not is_valid:
      model.add_error(self.pretty_property_name or self.property_name, message)
    return is_valid
1054534
function initModelValidate (args) {
    var controller = this
    var model = this.model
    // if model does not have schema do not add validate controller
    if (!model.schemaData) {
        return
    }
    // get accountId column
    var accountIdColumn = model.columnName('accountId') 
    // set role to authenticated if model requires account id
    var role = args.defaultRole || (accountIdColumn && model.columns[accountIdColumn].null === false ? 'authenticated' : 'all')
    // index inputs
    var input = {
        // validate schema data
        meta: 'query.meta',
    }
    // instance data is in body under model name
    input[model.name] = 'body.'+model.name
    // create path if it does not exist
    if (!this.paths['/validate']) {
        this.paths['/validate'] = {}
    }
    // add POST /validate handler
    this.paths['/validate'].post = [
        {
            before: function (args) {
                // do validation
                return beforeValidate(controller, args)
            },
            input: input,
            method: function (args) {
                // if before didnt have errors data is valid
                return {valid: true}
            },
            role: role,
            methodName: 'validate',
        },
    ]
}
243666
def type=(type)
      validator = EnumAttributeValidator.new('String', ["PHYSICAL", "MOBILE"])
      unless validator.valid?(type)
        fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}."
      end
      @type = type
    end
2481
function(value, attr, required, model, computed) {
        var isRequired = _.isFunction(required) ? required.call(model, value, attr, computed) : required;
        if(!isRequired && !hasValue(value)) {
          return false; // overrides all other validators
        }
        if (isRequired && !hasValue(value)) {
          return this.format(getMessageKey(this.msgKey, defaultMessages.required), this.formatLabel(attr, model));
        }
      }
1120271
public void validateFor(final int type) throws ValueFormatException
   {
      if (constraints == null || constraints.length <= 0)
      {
         return;
      }

      if (type == PropertyType.DATE)
      {
         for (String constrString : constraints)
         {
            try
            {
               MinMaxConstraint constraint = parseAsMinMax(constrString);
               if (constraint.getMin().getThreshold().length() > 0)
               {
                  JCRDateFormat.parse(constraint.getMin().getThreshold());
               }

               if (constraint.getMax().getThreshold().length() > 0)
               {
                  JCRDateFormat.parse(constraint.getMax().getThreshold());
               }
            }
            catch (ValueFormatException e)
            {
               throw new ValueFormatException("Wrong DATE constraint format " + constrString, e);
            }
            catch (ConstraintViolationException e)
            {
               throw new ValueFormatException("Wrong DATE constraint format " + constrString, e);
            }
         }
      }
      else if (type == PropertyType.DOUBLE)
      {
         for (String constrString : constraints)
         {
            try
            {
               MinMaxConstraint constraint = parseAsMinMax(constrString);
               if (constraint.getMin().getThreshold().length() > 0)
               {
                  Double.parseDouble(constraint.getMin().getThreshold());
               }
               if (constraint.getMax().getThreshold().length() > 0)
               {
                  Double.parseDouble(constraint.getMax().getThreshold());
               }
            }
            catch (NumberFormatException e)
            {
               throw new ValueFormatException("Wrong DOUBLE constraint format " + constrString, e);
            }
            catch (ConstraintViolationException e)
            {
               throw new ValueFormatException("Wrong DOUBLE constraint format " + constrString, e);
            }
         }
      }
      else if (type == PropertyType.LONG || type == PropertyType.BINARY)
      {
         for (String constrString : constraints)
         {
            try
            {
               MinMaxConstraint constraint = parseAsMinMax(constrString);
               if (constraint.getMin().getThreshold().length() > 0)
               {
                  Long.parseLong(constraint.getMin().getThreshold());
               }
               if (constraint.getMax().getThreshold().length() > 0)
               {
                  Long.parseLong(constraint.getMax().getThreshold());
               }
            }
            catch (NumberFormatException e)
            {
               throw new ValueFormatException("Wrong LONG (or BINARY size) constraint format " + constrString, e);
            }
            catch (ConstraintViolationException e)
            {
               throw new ValueFormatException("Wrong LONG (or BINARY size) constraint format " + constrString, e);
            }
         }
      }
      else if (type == PropertyType.BOOLEAN)
      {
         for (String constrString : constraints)
         {
            if (!constrString.equalsIgnoreCase("true") && !constrString.equalsIgnoreCase("false"))
            {
               throw new ValueFormatException("Wrong BOOLEAN constraint format: " + constrString);
            }
         }
      }
   }
1249746
public void setModelType(ModelType type) {
		this.modelType = type;

		if (type != ModelType.AUTO) {
			this.type = type.getJsName();
		}
		else {
			this.type = null;
		}
	}
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 );
	}
7585
function isValidScalar(context: ValidationContext, node: ValueNode): void {
  // Report any error at the full type expected by the location.
  const locationType = context.getInputType();
  if (!locationType) {
    return;
  }

  const type = getNamedType(locationType);

  if (!isScalarType(type)) {
    context.reportError(
      new GraphQLError(
        badValueMessage(
          inspect(locationType),
          print(node),
          enumTypeSuggestion(type, node),
        ),
        node,
      ),
    );
    return;
  }

  // Scalars determine if a literal value is valid via parseLiteral() which
  // may throw or return an invalid value to indicate failure.
  try {
    const parseResult = type.parseLiteral(node, undefined /* variables */);
    if (isInvalid(parseResult)) {
      context.reportError(
        new GraphQLError(
          badValueMessage(inspect(locationType), print(node)),
          node,
        ),
      );
    }
  } catch (error) {
    // Ensure a reference to the original error is maintained.
    context.reportError(
      new GraphQLError(
        badValueMessage(inspect(locationType), print(node), error.message),
        node,
        undefined,
        undefined,
        undefined,
        error,
      ),
    );
  }
}