Helper to run validators on the field data.
355633
def _validate(self, data):
        """"""

        errors = {}

        # if the validator is not enabled, return the empty error dict
        if not self._enabled:
            return errors

        for field in self.validators:

            field_errors = []

            for validator in self.validators[field]:
                try:
                    validator(data.get(field, None))
                except ValidationError as e:
                    field_errors += e.messages

            # if there were errors, cast to ErrorList for output convenience
            if field_errors:
                errors[field] = ErrorList(field_errors)

        return errors
968130
function runValidator(param, paramName) {
  if (!validator(param)) {
    console.log('Error message from validator: ' + validator.errors[0].message);
    console.log('Error message from validator: ', validator.errors[0]);
    throw new error.MalformedAstError(
      paramName +
        ' must be well-defined and follow the AST schema. ' +
        'Object: ' +
        JSON.stringify(param)
    );
  }
}
994654
def _validated(self, data):
        """"""
        for sub in self.schemas:
            data = sub(data)
        return data
526621
def run(self, value, errors, request):
        """"""
        value = self.id_validator(value, errors, request)
        if errors:
            return None
        if self.fetch_by:
            thing = self.cls.fetch_by(**{self.fetch_by: value})
        else:
            thing = self.cls.fetch_by_id(value)
        if not thing and self.source == SOURCE_MATCHDICT:
            # If part of the URL we should have a not-found error
            raise HTTPNotFound()
        elif not thing:
            self.add_error(errors, 'Invalid {0}'
                           .format(self.cls.__name__))
        return thing
261768
def validate_matches(other):
    
    def matches_validator(field, data):
        if field.value is None:
            return
        if not (field.value == data.get(other)):
            raise ValidationError('matches', other=other)
    return matches_validator
427691
public void validateAllFields() {

        CmsValidationController validationController = new CmsValidationController(
            m_fields.values(),
            createValidationHandler());
        validationController.setFormValidator(m_validatorClass);
        validationController.setFormValidatorConfig(createValidatorConfig());
        startValidation(validationController);
    }
519431
protected function make_fields_validation() {
		foreach ( $this->fields as $key => $field ) {
			if ( $this->maybe_skip_field( $field ) ) {
				continue;
			}

			if ( $rules = $field->get_option( 'validate' ) ) {
				$attributes = ( new Rules_Parser( $field ) )->parse( $rules );
				$field->set_attribute( $attributes );
			}
		}
	}
1348157
def run_validators(self, value):
        """"""
        errors = []
        for validator in self.validators:
            try:
                validator(value)
            except ValidationError as error:
                errors.extend(error.messages)
        if errors:
            raise ValidationError(errors)
472161
def _validate_data(self, data: dict):
        
        log.debug("validating provided data")
        e = best_match(self.validator.iter_errors(data))
        if e:
            custom_error_key = f"error_{e.validator}"
            msg = (
                e.schema[custom_error_key]
                if e.schema.get(custom_error_key)
                else e.message
            )
            raise BadArguments(validation_error=msg, provider=self.name, data=data)
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,
                )
921736
def _validated(self, data):
        """"""
        try:
            return self.convert(data)
        except (TypeError, ValueError) as ex:
            raise NotValid(*ex.args)
562221
def _populate_validated_data_with_sub_field_data(self, validated_data):
        
        for fieldname, field in self.get_fields().items():
            if isinstance(field, ModelSubSerializer):
                field_data = validated_data.pop(fieldname, None)
                if field_data:
                    validated_data.update(field_data)
1192674
def validate(self):
        """"""
        if not isinstance(self.field, LocalField):
            raise TypeError(u'Expected LocalField field, got: {} {}'.format(
                type(self.field).__name__, self.field))

        if not isinstance(self.lower_bound, Expression):
            raise TypeError(u'Expected Expression lower_bound, got: {} {}'.format(
                type(self.lower_bound).__name__, self.lower_bound))

        if not isinstance(self.upper_bound, Expression):
            raise TypeError(u'Expected Expression upper_bound, got: {} {}'.format(
                type(self.upper_bound).__name__, self.upper_bound))
1102636
def validate(self, data=None):
        

        errors = {}

        data = self._getData(data)

        # validate each field, one by one
        for name, field in self.fields.items():
            try:
                field.clean(data.get(name))
            except ValidationError, e:
                errors[name] = e.messages
            except AttributeError, e:
                raise ValidationError('data should be of type dict but is %s' % (type(data),))

        # check for extra fields
        extras = set(data.keys()) - set(self.fields.keys())
        if extras:
            errors[', '.join(extras)] = ['field(s) not allowed']

        # if errors, raise ValidationError
        if errors:
            raise ValidationError(errors)
1322676
private function callValidators($value, ValidationField $field) {
        $valid = true;

        // Strip array references in the name except for the last one.
        $key = $field->getSchemaPath();
        if (!empty($this->validators[$key])) {
            foreach ($this->validators[$key] as $validator) {
                $r = call_user_func($validator, $value, $field);

                if ($r === false || Invalid::isInvalid($r)) {
                    $valid = false;
                }
            }
        }

        // Add an error on the field if the validator hasn't done so.
        if (!$valid && $field->isValid()) {
            $field->addError('invalid', ['messageCode' => 'The value is invalid.']);
        }
    }
55991
def validate(self, data, all_data=None):
        '''
        
        '''
        if data is None:
            return True, False
        else:
            return super(BooleanField, self).validate(data, all_data)
266962
def validate(self, value):
        """"""
        if value is not None:
            if not isinstance(value, list):
                raise ValidationError("field must be a list")

            for index, element in enumerate(value):
                try:
                    self.inner.validate(element)
                except ValidationError as error:
                    raise ValidationError("invalid element {}: {}".format(
                        index,
                        error.args[0],
                    ))

        super().validate(value)