Validates fields are valid and maps pseudo-fields to actual fields
    for a given model class.
970011
def parse_selectors(model, fields=None, exclude=None, key_map=None, **options):
    
    fields = fields or DEFAULT_SELECTORS
    exclude = exclude or ()
    key_map = key_map or {}
    validated = []

    for alias in fields:
        # Map the output key name to the actual field/accessor name for
        # the model
        actual = key_map.get(alias, alias)

        # Validate the field exists
        cleaned = resolver.get_field(model, actual)

        if cleaned is None:
            raise AttributeError('The "{0}" attribute could not be found '
                                 'on the model "{1}"'.format(actual, model))

        # Mapped value, so use the original name listed in `fields`
        if type(cleaned) is list:
            validated.extend(cleaned)
        elif alias != actual:
            validated.append(alias)
        else:
            validated.append(cleaned)

    return tuple([x for x in validated if x not in exclude])
776809
def create(self, validated_data):
        
        if self.context.get('parent_field') \
            and self.context.get('parent_instance'):
            validated_data.update({
                self.context.get('parent_field'):
                self.context.get('parent_instance')})
        instance = self.Meta.model(**validated_data)
        instance.full_clean()
        instance.save()
        return instance
973706
public function validateModelClass()
    {
        if ($this->isReservedKeyword($this->modelClass)) {
            $this->addError('modelClass', 'Class name cannot be a reserved PHP keyword.');
        }
        if ((empty($this->tableName) || substr_compare($this->tableName, '*', -1, 1)) && $this->modelClass == '') {
            $this->addError('modelClass', 'Model Class cannot be blank if table name does not end with asterisk.');
        }
    }
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 );
			}
		}
	}
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
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 );
    }
1017114
private void evaluateObject() {
        if (evaluatedClasses.contains(clazz)) {
            return;
        }

        Field[] fields = clazz.getDeclaredFields();

        for (Field field : fields) {
            if (field.isAnnotationPresent(ModelField.class)
            && !isAllowed(field)) {
                throw new RuntimeException("Field '"
                        + field.getName()
                        + "' has type '" + field.getType().getSimpleName()
                        + "' that is not allowed!");
            }
        }

        evaluatedClasses.add(clazz);
    }
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,
                )
1302754
def validate_object(obj, field_validators=None, non_field_validators=None,
                    schema=None, context=None):
    
    if schema is None:
        schema = {}
    if context is None:
        context = {}
    if field_validators is None:
        field_validators = ValidationDict()
    if non_field_validators is None:
        non_field_validators = ValidationList()

    from flex.validation.schema import (
        construct_schema_validators,
    )
    schema_validators = construct_schema_validators(schema, context)
    if '$ref' in schema_validators and hasattr(schema_validators['$ref'], 'validators'):
        ref_ = field_validators.pop('$ref')
        for k, v in ref_.validators.items():
            if k not in schema_validators:
                schema_validators.add_validator(k, v)

    if 'discriminator' in schema:
        schema_validators = add_polymorphism_requirements(obj, schema, context, schema_validators)
        # delete resolved discriminator to avoid infinite recursion
        del schema['discriminator']

    schema_validators.update(field_validators)
    schema_validators.validate_object(obj, context=context)
    non_field_validators.validate_object(obj, context=context)
    return obj
740741
def validate_fields(func):
    """"""
    @functools.wraps(func)
    def decorated(instance, *args, **kwargs):
        """The decorator function."""
        data = request.get_json(force=True, silent=True)
        if not data:
            raise BadRequestException('No data received from request')
        for key in data:
            if key not in (
                    instance.__model__.required() +
                    instance.__model__.optional()):
                raise BadRequestException('Unknown field [{}]'.format(key))
        missing = set(instance.__model__.required()) - set(data)
        if missing:
            message = 'The following required fields are missing: ' + ', '.join(missing)
            raise BadRequestException(message)
        return func(instance, *args, **kwargs)
    return decorated
1270464
public void validate() {

		ErrorDetails details = null;
		if( this.fileName != null )
			details = ErrorDetails.file( this.fileName );

		if( this.failed ) {
			this.errors.add( new ModelError( ErrorCode.REC_TARGET_INVALID_FILE_OR_CONTENT, this.modelObject, details ));

		} else {
			String id = this.props.getProperty( Constants.TARGET_PROPERTY_ID );
			if( Utils.isEmptyOrWhitespaces( id ))
				this.errors.add( new ModelError( ErrorCode.REC_TARGET_NO_ID, this.modelObject, details ));

			String handler = this.props.getProperty( Constants.TARGET_PROPERTY_HANDLER );
			if( Utils.isEmptyOrWhitespaces( handler ))
				this.errors.add( new ModelError( ErrorCode.REC_TARGET_NO_HANDLER, this.modelObject, details ));

			String name = this.props.getProperty( Constants.TARGET_PROPERTY_NAME );
			if( Utils.isEmptyOrWhitespaces( name ))
				this.errors.add( new ModelError( ErrorCode.REC_TARGET_NO_NAME, this.modelObject, details ));
		}
	}
917798
def _cooked_fields(self, dj_fields):
        
        from django.db import models

        valids = []
        for field in dj_fields:
            try:
                dj_field, _, _, _ = self.model._meta.get_field_by_name(field)
                if isinstance(dj_field, models.ForeignKey):
                    valids.append((field + "_id", field, dj_field))
                else:
                    valids.append((field, field, dj_field))
            except models.FieldDoesNotExist:
                valids.append((field, field, None))
        return valids
600072
def validate(self, raw_data, **kwargs):
        
        super(BooleanField, self).validate(raw_data, **kwargs)
        if isinstance(raw_data, string_types):
            valid_data = raw_data.strip().lower() == 'true'
        elif isinstance(raw_data, bool):
            valid_data = raw_data
        else:
            valid_data = raw_data > 0
        return valid_data
1373592
def create_validated_fields(self):
        
        model_class = self.model_class
        fields = self.fields
        maximum = self.maximum
        objects = []

        for n in range(maximum):
            data_dict = {}
            for field in fields:

                def default_assign(func):
                    data_dict[field['field_name']] = func

                def string_assign(func):
                    data_dict[field['field_name']] = str(func)

                if field['field_type'] == 'BigIntegerField':  # values from -9223372036854775808 to 9223372036854775807
                    default_assign(random.randint(-9223372036854775808, 9223372036854775807))
                elif field['field_type'] == 'BinaryField':  # b'', self.randomBinaryField()
                    default_assign(self.randomBinaryField())
                elif field['field_type'] == 'BooleanField':  # True/False
                    default_assign(self.randomize([True, False]))
                elif field['field_type'] == 'CharField':  # self.randomCharField()
                    string_assign(self.randomCharField(model_class, field['field_name']))
                elif field['field_type'] == 'CommaSeparatedIntegerField':  # self.randomCommaSeparatedIntegerField()
                    string_assign(self.randomCommaSeparatedIntegerField())
                elif field['field_type'] == 'DateField':  # '2016-10-11'
                    string_assign(str(datetime.datetime.now().date()))
                elif field['field_type'] == 'DateTimeField':  # '2016-10-11 00:44:08.864285'
                    string_assign(str(datetime.datetime.now()))
                elif field['field_type'] == 'DecimalField':  # self.randomDecimalField()
                    default_assign(self.randomDecimalField(model_class, field['field_name']))
                elif field['field_type'] == 'DurationField':  # such as 1 day, 4 days or else.
                    default_assign(datetime.timedelta(days=random.randint(1, 10)))
                elif field['field_type'] == 'EmailField':  # self.randomEmailField()
                    string_assign(self.randomEmailField())
                elif field['field_type'] == 'FileField':  # self.randomFileField()
                    string_assign(self.randomFileField())
                elif field['field_type'] == 'FloatField':  # 1.92, 0.0, 5.0, or else.
                    default_assign(float(("%.2f" % float(random.randint(0, 100) / 13))))
                elif field['field_type'] == 'ImageField':  # self.randomImageField()
                    string_assign(self.randomImageField())
                elif field['field_type'] == 'IntegerField':  # values from -2147483648 to 2147483647
                    default_assign(random.randint(-2147483648, 2147483647))
                elif field['field_type'] == 'GenericIPAddressField':  # self.randomGenericIPAddressField()
                    string_assign(self.randomGenericIPAddressField())
                elif field['field_type'] == 'NullBooleanField':  # by Default is None/null
                    default_assign(self.randomize([None, True, False]))
                elif field['field_type'] == 'PositiveIntegerField':  # values from 0 to 2147483647
                    default_assign(random.randint(0, 2147483647))
                elif field['field_type'] == 'PositiveSmallIntegerField':  # values from 0 to 32767
                    default_assign(random.randint(0, 32767))
                elif field['field_type'] == 'SlugField':  # self.randomSlugField()
                    string_assign(self.randomSlugField())
                elif field['field_type'] == 'SmallIntegerField':  # values from -32768 to 32767
                    default_assign(random.randint(-32768, 32767))
                elif field['field_type'] == 'TextField':  # self.randomTextField()
                    string_assign(self.randomTextField())
                elif field['field_type'] == 'TimeField':  # accepts the same as DateField
                    string_assign(str(datetime.datetime.now().date()))
                elif field['field_type'] == 'URLField':  # self.randomURLField()
                    string_assign(self.randomURLField())
                elif field['field_type'] == 'UUIDField':  # self.randomUUIDField()
                    string_assign(self.randomUUIDField())
                elif field['field_type'] == 'ForeignKey':  # self.getOrCreateForeignKey()
                    default_assign(self.getOrCreateForeignKey(model_class, field['field_name']))
                # elif field['field_type'] == 'OneToOneField':  # pk/id -> not fixed yet.
                #    default_assign(self.randomize([1, ]))
                # Unsolved: need specific pk/id

            obj = model_class.objects.create(**data_dict)

            # Because the Relationship Model need specific id from the object,
            # so, i handle it after created the object.
            for field in fields:
                if field['field_type'] == 'ManyToManyField':
                    # Find the instance model field from `obj` already created before.
                    instance_m2m = getattr(obj, field['field_name'])
                    objects_m2m = instance_m2m.model.objects.all()

                    # Djipsum only create the `ManyToManyField` if the related object is exists.
                    if objects_m2m.exists():
                        ids_m2m = [i.pk for i in objects_m2m]
                        random_decission = random.sample(
                            range(min(ids_m2m), max(ids_m2m)), max(ids_m2m) - 1
                        )
                        # Let me know if the `random_decission` has minimum objects to be choice.
                        if len(random_decission) <= 2:
                            random_decission = [self.randomize(ids_m2m)]
                        related_objects = [
                            rel_obj for rel_obj in objects_m2m
                            if rel_obj.pk in random_decission
                        ]
                        # adding the `ManyToManyField`
                        instance_m2m.add(*related_objects)
            try:
                obj.save_m2m()
            except:
                obj.save()
            objects.append(obj)
        return objects
321189
function(set) {
        var dtype, valids, typeClass, self = this;
        //
        if (utils.isString(set)) {
            // resolve data type
            typeClass = this.dataTypes.get(set);
            if (typeClass) { dtype = new typeClass(); }
        }
        else if (set) {
            utils.each(set, function(key, val) {
                if (!utils.hasOwn(set, key)) {
                    return;
                }
                if (key.toLowerCase() === 'type') {
                    // resolve data type
                    typeClass = self.dataTypes.get(val);
                    if (typeClass) { dtype = new typeClass(); }
                } else {
                    // resolve validators
                    typeClass = self.validators.get(key);
                    if (typeClass) {
                        if (!valids) { valids = []; }
                        valids.push(new typeClass(set[key]));
                    }
                }
            });
        }
        return new modellingMetas(dtype, valids);
    }
727486
function _validateIsModel(model) {
  let parentClass = Object.getPrototypeOf(model);
  while (parentClass.name !== 'Model' && parentClass.name !== '') {
    parentClass = Object.getPrototypeOf(parentClass);
  }
  validationUtils.booleanTrue(
    parentClass.name === 'Model',
    'Parameter is not an Objection.js model'
  );
}
726640
def validate(self, model, checks=[]):
        """"""
        records = self.data.to_dict("records")
        self.evaluate_report(
            validate(records, headers=list(records[0]),
                     preset='table', schema=self.schema,
                     order_fields=True, custom_checks=checks))