Skip to main content

validate_model_fields

No overview available.

def validate_model_fields(
model_name: string,
data: dict,
strict: boolean = false
) - > bool

Validates that the provided dictionary contains all required fields for a specific model type and that field values meet expected constraints.

Parameters

NameTypeDescription
model_namestringThe identifier of the model schema to validate against (e.g., 'User', 'Product').
datadictThe dictionary of key-value pairs representing the model instance to be validated.
strictboolean = falseIf set to True, validation will fail if unknown fields not defined in the schema are present.

Returns

TypeDescription
boolTrue if all validation checks pass, otherwise False or raises a ValidationError depending on configuration.