Boolean
- class Boolean
Bases:
CommonBaseModel
Represents a boolean data type with enhanced attributes for engineering applications.
- value
The actual boolean value.
- Type:
bool
- units
Units of the variable, typically ‘unitless’ for boolean types.
- Type:
str
- description
A brief description of the variable.
- Type:
Optional[str]
- default
Default boolean value of the variable, if any.
- Type:
Optional[bool]
- Raises:
ValidationError – If the input value does not meet the validation criteria.
Attributes Summary
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Methods Summary
validate_default
(value, values)Validate and convert the default value to a boolean if it's provided as a string.
Attributes Documentation
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow', 'protected_namespaces': (), 'validate_assignment': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Methods Documentation
- classmethod validate_default(value, values)
Validate and convert the default value to a boolean if it’s provided as a string.
- Parameters:
value (bool | None) – The default value being validated.
values (dict) – The dictionary containing the field values.
- Returns:
The validated default value.
- Raises:
ValueError – If the default value is a string that cannot be converted to a boolean.
- Return type:
bool | None
Methods:
validate_default
(value, values)Validate and convert the default value to a boolean if it's provided as a string.
Attributes:
__setattr__ handlers.
- classmethod validate_default(value, values)
Validate and convert the default value to a boolean if it’s provided as a string.
- Parameters:
value (bool | None) – The default value being validated.
values (dict) – The dictionary containing the field values.
- Returns:
The validated default value.
- Raises:
ValueError – If the default value is a string that cannot be converted to a boolean.
- Return type:
bool | None
- __pydantic_setattr_handlers__: ClassVar[Dict[str, Callable[[BaseModel, str, Any], None]]] = {}
__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__