Pydantic Field¶
FastDepends is able to use pydantic.Field as a default parameter to validate incoming argument
1 2 3 4 5 6 | |
Pydantic Documentation
To get more information and usage examples, please visit official pydantic documentation
All available fields are:
default: (a positional argument) the default value of the field. Since theFieldreplaces the field's default, this first argument can be used to set the default. Use ellipsis (...) to indicate the field is required.default_factory: a zero-argument callable that will be called when a default value is needed for this field. Among other purposes, this can be used to set dynamic default values. It is forbidden to set bothdefaultanddefault_factory.alias: the public name of the fieldconst: this argument must be the same as the field's default value if present.gt: for numeric values (int,float,Decimal), adds a validation of "greater than" and an annotation ofexclusiveMinimumto the JSON Schemage: for numeric values, this adds a validation of "greater than or equal" and an annotation ofminimumto the JSON Schemalt: for numeric values, this adds a validation of "less than" and an annotation ofexclusiveMaximumto the JSON Schemale: for numeric values, this adds a validation of "less than or equal" and an annotation ofmaximumto the JSON Schemamultiple_of: for numeric values, this adds a validation of "a multiple of" and an annotation ofmultipleOfto the JSON Schemamax_digits: forDecimalvalues, this adds a validation to have a maximum number of digits within the decimal. It does not include a zero before the decimal point or trailing decimal zeroes.decimal_places: forDecimalvalues, this adds a validation to have at most a number of decimal places allowed. It does not include trailing decimal zeroes.min_items: for list values, this adds a corresponding validation and an annotation ofminItemsto the JSON Schemamax_items: for list values, this adds a corresponding validation and an annotation ofmaxItemsto the JSON Schemaunique_items: for list values, this adds a corresponding validation and an annotation ofuniqueItemsto the JSON Schemamin_length: for string values, this adds a corresponding validation and an annotation ofminLengthto the JSON Schemamax_length: for string values, this adds a corresponding validation and an annotation ofmaxLengthto the JSON Schemaallow_mutation: a boolean which defaults toTrue. When False, the field raises aTypeErrorif the field is assigned on an instance. The model config must setvalidate_assignmenttoTruefor this check to be performed.regex: for string values, this adds a Regular Expression validation generated from the passed string and an annotation ofpatternto the JSON Schema