Skip to content

NameRequired

faststream.broker.schemas.NameRequired #

NameRequired(name: str, **kwargs: Any)

Bases: BaseModel

A class to represent a required name.

METHOD DESCRIPTION
__eq__

object) -> bool: Check if the given value is equal to the current instance.

validate

Type[NameRequiredCls], value: Union[str, NameRequiredCls]) -> NameRequiredCls: Validate the given value and return a NameRequiredCls instance.

validate

Type[NameRequiredCls], value: None) -> None: Validate the given value and return None.

validate

Type[NameRequiredCls], value: Union[str, NameRequiredCls, None]) -> Optional[NameRequiredCls]: Validate the given value and return an optional NameRequiredCls instance.

Note

The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)

This is a Python function.

PARAMETER DESCRIPTION
name

The name of the object.

TYPE: str

**kwargs

Additional keyword arguments.

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
None

None.

Note

The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)

Source code in faststream/broker/schemas.py
def __init__(self, name: str, **kwargs: Any) -> None:
    """This is a Python function.

    Args:
        name (str): The name of the object.
        **kwargs (Any): Additional keyword arguments.

    Returns:
        None.
    !!! note

        The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
    """
    super().__init__(name=name, **kwargs)

name class-attribute instance-attribute #

name: str = Field(...)

validate classmethod #

validate(
    value: Union[str, NameRequiredCls, None]
) -> Optional[NameRequiredCls]

Validates a value.

PARAMETER DESCRIPTION
value

The value to be validated.

TYPE: Union[str, NameRequiredCls, None]

RETURNS DESCRIPTION
Optional[NameRequiredCls]

The validated value.

Note

The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)

Source code in faststream/broker/schemas.py
@classmethod
def validate(
    cls: Type[NameRequiredCls], value: Union[str, NameRequiredCls, None]
) -> Optional[NameRequiredCls]:
    """Validates a value.

    Args:
        value: The value to be validated.

    Returns:
        The validated value.
    !!! note

        The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
    """
    if value is not None:
        if isinstance(value, str):
            value = cls(value)
    return value

Last update: 2023-11-13