Skip to content

NameRequired

faststream.broker.schemas.NameRequired #

NameRequired(name)

Required name option object.

Source code in faststream/broker/schemas.py
def __init__(self, name: str) -> None:
    self.name = name

name instance-attribute #

name = name

validate classmethod #

validate(value: Union[str, NameRequiredCls], **kwargs: Any) -> NameRequiredCls
validate(value: None, **kwargs: Any) -> None
validate(value, **kwargs)

Factory to create object.

Source code in faststream/broker/schemas.py
@classmethod
def validate(
    cls: Type[NameRequiredCls],
    value: Union[str, NameRequiredCls, None],
    **kwargs: Any,
) -> Optional[NameRequiredCls]:
    """Factory to create object."""
    if value is not None and isinstance(value, str):
        value = cls(value, **kwargs)
    return value