33# cython: wraparound=False
44# cython: cdivision=True
55
6+ from flask_inputfilter.models.cimports cimport BaseFilter, BaseValidator, ExternalApiConfig
67
78cdef class FieldDescriptor:
89 """
@@ -18,14 +19,23 @@ cdef class FieldDescriptor:
1819 - **default** (*Any*): Default value if field is missing.
1920 - **fallback** (*Any*): Fallback value if validation fails.
2021 - **filters** (*Optional[list[BaseFilter]]*): List of filters to apply.
21- - **validators** (*Optional[list[BaseValidator]]*): List of validators to apply.
22- - **steps** (*Optional[list[Union[BaseFilter, BaseValidator]]]*): List of combined filters and validators.
23- - **external_api** (*Optional[ExternalApiConfig]*): External API configuration.
24- - **copy** (*Optional[str]*): Field to copy value from if this field is missing.
22+ - **validators** (*Optional[list[BaseValidator]]*): List of validators
23+ to apply.
24+ - **steps** (*Optional[list[Union[BaseFilter, BaseValidator]]]*): List of
25+ combined filters and validators.
26+ - **external_api** (*Optional[ExternalApiConfig]*): External API
27+ configuration.
28+ - **copy** (*Optional[str]*): Field to copy value from if this field
29+ is missing.
30+ - **computed** (*Optional[Callable[[dict[str, Any]], Any]]*): A callable
31+ that computes the field value from validated data.
32+ - **input_filter** (*Optional[type]*): An InputFilter class for
33+ nested validation.
2534
2635 **Expected Behavior:**
2736
28- Automatically registers field configuration during class creation and provides
37+ Automatically registers field configuration during class creation and
38+ provides
2939 attribute access to validated field values.
3040 """
3141
@@ -34,12 +44,13 @@ cdef class FieldDescriptor:
3444 bint required = False ,
3545 object default = None ,
3646 object fallback = None ,
37- list filters = None ,
38- list validators = None ,
39- list steps = None ,
40- object external_api = None ,
47+ list[BaseFilter] filters = None ,
48+ list[BaseValidator] validators = None ,
49+ list[BaseFilter | BaseValidator] steps = None ,
50+ ExternalApiConfig external_api = None ,
4151 str copy = None ,
4252 object computed = None ,
53+ object input_filter = None ,
4354 ) -> None:
4455 """
4556 Initialize a field descriptor.
@@ -62,6 +73,8 @@ cdef class FieldDescriptor:
6273 from .
6374 - ** computed** (* Optional[Callable[[dict [str , Any]], Any]]* ): A callable
6475 that computes the field value from validated data.
76+ - ** input_filter** (* Optional[type ]* ): An InputFilter class
77+ for nested validation.
6578 """
6679 self.required = required
6780 self._default = default
@@ -72,6 +85,7 @@ cdef class FieldDescriptor:
7285 self.external_api = external_api
7386 self.copy = copy
7487 self.computed = computed
88+ self.input_filter = input_filter
7589 self.name = None
7690
7791 @property
@@ -147,6 +161,11 @@ cdef class FieldDescriptor:
147161 f"required={self.required}, "
148162 f"default={self.default!r}, "
149163 f"filters={len(self.filters)}, "
150- f"validators={len(self.validators)}"
164+ f"validators={len(self.validators)}, "
165+ f"steps={len(self.steps)}, "
166+ f"external_api={self.external_api!r}, "
167+ f"copy={self.copy!r}, "
168+ f"computed={self.computed!r}, "
169+ f"input_filter={self.input_filter!r}"
151170 f")"
152171 )
0 commit comments