RegexField
This class provides a specialized character field that validates input against a specific regular expression. It supports both string-based patterns and compiled regular expression objects, automatically managing a regex validator to ensure data integrity. By default, the field disables whitespace stripping to preserve the exact formatting required by the pattern.
Attributes
| Attribute | Type | Description |
|---|---|---|
| regex | string or compiled regular expression object | regex can be either a string or a compiled regular expression object. |
Constructor
Signature
def RegexField(
regex: [Union](../../contrib/gis/db/models/functions/union.md?sid=django_contrib_gis_db_models_functions_union)[str, Pattern],
**kwargs: dict
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| regex | [Union](../../contrib/gis/db/models/functions/union.md?sid=django_contrib_gis_db_models_functions_union)[str, Pattern] | A string or a compiled regular expression object used for validation. |
| **kwargs | dict | Additional keyword arguments passed to the parent CharField constructor. |