Validatie a field
770352
def validateField(self, field) :
        """"""
        if field not in self.validators and not self.collection._validation['allow_foreign_fields'] :
            raise SchemaViolation(self.collection.__class__, field)

        if field in self.store:
            if isinstance(self.store[field], DocumentStore) :
                return self[field].validate()
            
            if field in self.patchStore :
                return self.validators[field].validate(self.patchStore[field])
            else :
                try :
                    return self.validators[field].validate(self.store[field])
                except ValidationError as e:
                    raise ValidationError( "'%s' -> %s" % ( field, str(e)) )
                except AttributeError:
                    if isinstance(self.validators[field], dict) and not isinstance(self.store[field], dict) :
                        raise ValueError("Validator expected a sub document for field '%s', got '%s' instead" % (field, self.store[field]) )
                    else :
                        raise
        return True
183484
function (Schema, data) {
		var schemaKey = _.keys(data)[0];

		var mainSchema = this._parseSchemaHashKey(Schema, schemaKey);

		iterate.recursiveEach(data[schemaKey], mainSchema, function (v, k, schema) {
			if (/^=+$/.test(k)) {
				schema.validate(v);
				return;
			}

			schema = this._parseAndAddField(Schema, k, schema);
			if (_.isArray(v)) {
				schema.validate(v);
				return;
			}

			return schema;
		}, this);

		return mainSchema;
	}
304049
def validate(self):
        """"""
        for name, field in self:
            try:
                field.validate_for_object(self)
            except ValidationError as error:
                raise ValidationError(
                    "Error for field '{name}'.".format(name=name),
                    error,
                )
351127
def _validate_items(self, items, field, values):
        
        if len(items) != len(values):
            self._error(field, errors.ITEMS_LENGTH, len(items), len(values))
        else:
            schema = dict(
                (i, definition) for i, definition in enumerate(items)
            )  # noqa: E501
            validator = self._get_child_validator(
                document_crumb=field,
                schema_crumb=(field, 'items'),  # noqa: E501
                schema=schema,
            )
            if not validator(
                dict((i, value) for i, value in enumerate(values)),
                update=self.update,
                normalize=False,
            ):
                self._error(field, errors.BAD_ITEMS, validator._errors)
881440
def validate(self, obj):
        """"""
        if self.path:
            for i in self.path:
                obj = obj[i]
        obj = obj[self.field]

        raise NotImplementedError('Validation is not implemented yet')
1055550
def validate(schema, value, noun='value'):
    
    errors = schema.errors(value)
    if errors:
        error_details = ''
        for error in errors:
            if error.pointer:
                error_details += '  - %s: %s\n' % (error.pointer, error.message)
            else:
                error_details += '  - %s\n' % error.message
        raise ValidationError('Invalid %s:\n%s' % (noun, error_details))
848757
def validate_fields(self, **kwargs):
        
        for field in self.fields:
            value = kwargs[field]
            required_type = self.fields[field]
            if type(value) != required_type:
                raise TypeError('{}.{} needs to be a {}, recieved: {}({})'.format(
                    self.name,
                    field,
                    required_type.__name__,
                    type(value).__name__,
                    value.__repr__()))
1109485
def validate(self, data):
        
        validator = self._schema.validator(self._id)
        validator.validate(data)
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
    })
  }
165444
def validate(self, value):
        """"""
        if value is not None and not isinstance(value, str):
            raise ValidationError("field must be a string")

        super().validate(value)
101363
protected void validateDate(String field, String min, String max, String errorKey, String errorMessage) {
		// validateDate(field, Date.valueOf(min), Date.valueOf(max), errorKey, errorMessage);  为了兼容 64位 JDK
		try {
			SimpleDateFormat sdf = new SimpleDateFormat(getDatePattern());
			validateDate(field, sdf.parse(min.trim()), sdf.parse(max.trim()), errorKey, errorMessage);
		} catch (Exception e) {
			addError(errorKey, errorMessage);
		}
	}
1106652
function validate(doc, schema, prefix, options) {
  schema.validate(doc, prefix, options);
}
1254939
def valid(self, instance, schema):
        """"""
        try:
            jsonschema.validate(instance, schema)
        except jsonschema.exceptions.ValidationError as ex:
            self.stderr.write("    VALIDATION ERROR: {}".format(instance['name'] if 'name' in instance else ''))
            self.stderr.write("        path:       {}".format(ex.path))
            self.stderr.write("        message:    {}".format(ex.message))
            self.stderr.write("        validator:  {}".format(ex.validator))
            self.stderr.write("        val. value: {}".format(ex.validator_value))
            return False

        try:
            # Check that default values fit field schema.
            for field in ['input', 'output', 'schema']:
                for schema, _, path in iterate_schema({}, instance.get(field, {})):
                    if 'default' in schema:
                        validate_schema({schema['name']: schema['default']}, [schema])
        except ValidationError:
            self.stderr.write("    VALIDATION ERROR: {}".format(instance['name']))
            self.stderr.write("        Default value of field '{}' is not valid.". format(path))
            return False

        return True
1029138
def validate(self, data):
        """"""
        try:
            schema_path = os.path.normpath(SCHEMA_ROOT)
            location = u'file://%s' % (schema_path)
            fs_resolver = resolver.LocalRefResolver(location, self.schema)
            jsonschema.Draft3Validator(self.schema, resolver=fs_resolver).validate(data)

        except jsonschema.ValidationError as exc:
            # print "data %s" % (data)
            raise jsonschema.exceptions.ValidationError(str(exc))
1200324
function parseValidateAttr(validateAttr, schema, validateFns) {

        // if an array, loop through and recurse
        if (_.isArray(validateAttr)) {
            _.each(validateAttr, function (validator) {
                parseValidateAttr(validator, schema, validateFns);
            });

            return;
        }

        // if validateAttr is a string, then assume it is field reference
        if (_.isString(validateAttr)) {
            _.extend(schema, getSchema(validateAttr));
        }
        else if (_.isFunction(validateAttr)) {
            validateFns.push(wrapFn(validateAttr));
        }
        else if (_.isObject(validateAttr)) {
            _.extend(schema,  validateAttr);
        }
    }
1050534
@Override
    public boolean validate(Field field, Object fieldValue, IRule... rules) throws RuleValidationException
    {

        if (rules == null)
        {
            return super.validate(field, fieldValue, this.ruleFactory.getJpaRules());
        }
        
        else
        {
            return super.validate(field, fieldValue, rules);
        }

    }
871549
function(field, allowedValues) {
    if (Array.isArray(field)) {
      return this.validateFieldsHelper(
        field,
        [allowedValues],
        this.validatesInclusionOf
      )
    }

    return this.validates(field, function() {
      var valid = true
      if (this[field]) valid = allowedValues.indexOf(this[field]) !== -1
      if (!valid)
        this.errors.add(
          field,
          'only allow one of [' + allowedValues.join(', ') + ']'
        )
      return valid
    })
  }