Skip to main content

Extra

This class provides a set of configuration options for controlling how extra attributes are handled during model initialization. It defines three distinct modes: allowing additional fields, ignoring them, or forbidding them entirely to ensure strict schema validation.

Attributes

AttributeTypeDescription
allowLiteral['allow'] = 'allow'Configuration setting that permits extra fields to be included in the model data during validation.
ignoreLiteral['ignore'] = 'ignore'Configuration setting that silently drops extra fields from the model data during validation.
forbidLiteral['forbid'] = 'forbid'Configuration setting that raises a validation error if extra fields are present in the model data.

Methods


allow()

def allow() - > str

Configures the model to permit and store extra fields provided during initialization that are not defined in the schema.

Returns

TypeDescription
strThe literal string 'allow' used as a configuration flag.

ignore()

def ignore() - > str

Configures the model to silently drop any extra fields provided during initialization that are not defined in the schema.

Returns

TypeDescription
strThe literal string 'ignore' used as a configuration flag.

forbid()

def forbid() - > str

Configures the model to raise a validation error if any extra fields are provided during initialization that are not defined in the schema.

Returns

TypeDescription
strThe literal string 'forbid' used as a configuration flag.