Composite Types¶
- class typerighter.types.composites.Container(*a, **kw)[source]¶
A Container is a foundational type, like Primitive, that allows some number of things to be held in a group, with no additional type checking past what a Primitive does.
New composite types should subclass this base type. It is not meant to be used directly.
- NATIVE¶
alias of
object
- is_coercible(value)¶
Checks a value for whether or not it can be converted to the correct type. Falls back to the stricter is_type_match if self.strict is True.
- Parameters
value (object) – The value to inspect
- is_falsy(value)[source]¶
Checks a value and responds saying whether the Type considers it falsy.
- Parameters
value (object) – The value to inspect
- Returns
True or False
- is_type_match(value)¶
Checks if a value is an instance of this Type’s native type. :param object value: The value to inspect
- to_native(value)¶
Converts a value to the native form of this type
- Parameters
value (object) – The value to convert
- to_primitive(value)¶
Converts a value to the primitive form of this type
- Parameters
value (object) – The value to convert
- to_schematic()¶
Returns a Type’s Schematic
- validate(value)¶
This validation function is the primary function responsible for calling all associated validators and for managing any details related to aggregation of validation results.
- Parameters
value (object) – The value to convert
- validate_choices(value)¶
Checks if a choices list has been set and then if value is in that list.
- class typerighter.types.composites.ListType(*a, **kw)[source]¶
A ListType is a Container implemented with a list.
- NATIVE¶
alias of
list
- is_coercible(value)¶
Checks a value for whether or not it can be converted to the correct type. Falls back to the stricter is_type_match if self.strict is True.
- Parameters
value (object) – The value to inspect
- is_falsy(value)¶
Checks a value and responds saying whether the Type considers it falsy.
- Parameters
value (object) – The value to inspect
- Returns
True or False
- is_type_match(value)¶
Checks if a value is an instance of this Type’s native type. :param object value: The value to inspect
- to_native(value, **kw)[source]¶
Converts a value to the native form of this type
- Parameters
value (object) – The value to convert
- to_primitive(value, **kw)[source]¶
Converts a value to the primitive form of this type
- Parameters
value (object) – The value to convert
- validate(value)¶
This validation function is the primary function responsible for calling all associated validators and for managing any details related to aggregation of validation results.
- Parameters
value (object) – The value to convert
- validate_choices(value)¶
Checks if a choices list has been set and then if value is in that list.
- class typerighter.types.composites.SumType(*a, **kw)[source]¶
Some languages call this a Union Type. The idea is to allow validation to pass if just one validator, from a list of two or more types, accepts it.
- NATIVE¶
alias of
object
- is_coercible(value)¶
Checks a value for whether or not it can be converted to the correct type. Falls back to the stricter is_type_match if self.strict is True.
- Parameters
value (object) – The value to inspect
- is_falsy(value)¶
Checks a value and responds saying whether the Type considers it falsy.
- Parameters
value (object) – The value to inspect
- Returns
True or False
- is_type_match(value)[source]¶
Checks if a value is an instance of this Type’s native type. :param object value: The value to inspect
- to_native(value, **kw)[source]¶
Converts a value to the native form of this type
- Parameters
value (object) – The value to convert
- to_primitive(value, **kw)[source]¶
Converts a value to the primitive form of this type
- Parameters
value (object) – The value to convert
- validate(value)¶
This validation function is the primary function responsible for calling all associated validators and for managing any details related to aggregation of validation results.
- Parameters
value (object) – The value to convert
- validate_choices(value)¶
Checks if a choices list has been set and then if value is in that list.