SIGN IN SIGN UP

Pr1499 (#1511)

* Fix allow_blank CharField format fields rejecting empty strings

    CharField subclasses with a string format (EmailField, URLField, IPAddressField)
    and allow_blank=True can return  as a valid response value, but the generated
    schema's format constraint (e.g. format: email, format: uri) rejects empty strings.

    Fix by wrapping the schema in anyOf at the end of _insert_field_validators, after
    all field validators (including MaxLengthValidator) have been applied. The anyOf
    has two branches: the full format-constrained schema for non-empty values, and
    {type: string, maxLength: 0} to allow empty strings.

    This preserves format validation for non-blank values while correctly allowing
    for fields where allow_blank=True. Outer-level schema metadata (readOnly, writeOnly,
    nullable, deprecated, title, description) is kept at the anyOf container level.

    Fixes #909

* Adapt anyOf to oneOf and test and fix broken tests #1499

---------

Co-authored-by: Luciano de la Iglesia <Luciano@opentug.com>
T
T. Franzel committed
9b18b302b697ba1a5e86271a7e4d090a5995cc21
Parent: 6e3c72e
Committed by GitHub <noreply@github.com> on 6/28/2026, 11:51:20 PM