Skip to main content

get_validation_alias

Retrieves the validation alias for a given model field, falling back to the field's regular alias if no validation alias is explicitly set.

def get_validation_alias(
field: ModelField
) - > str

Retrieves the validation alias for a given model field. This function is used to determine the name that should be used for validation purposes, falling back to the field's regular alias if no specific validation alias is defined.

Parameters

NameTypeDescription
fieldModelFieldThe Pydantic ModelField object from which to retrieve the validation alias.

Returns

TypeDescription
strThe validation alias for the field, or the field's regular alias if no validation alias is set.