Primitive types#

class oblate.fields.String(strict=True, **kwargs)#

Field representing a string (str) value.

This class is a subclass of Field and supports the features documented in that class.

ERR_INVALID_DATATYPE#

Error code raised when invalid data type is given in raw data.

ERR_COERCION_FAILED#

Error code raised when strict mode is disabled and given raw value cannot be converted to relevant data type.

Parameters:

strict (bool) – Whether to only allow string data types. If this is set to False, any value is type casted to string. Defaults to True.

class oblate.fields.Integer(strict=True, **kwargs)#

Field representing an integer (int) value.

This class is a subclass of Field and supports the features documented in that class.

ERR_INVALID_DATATYPE#

Error code raised when invalid data type is given in raw data.

ERR_COERCION_FAILED#

Error code raised when strict mode is disabled and given raw value cannot be converted to relevant data type.

Parameters:

strict (bool) – Whether to only allow integer data types. If this is set to False, any integer-castable value is type casted to integer. Defaults to True.

class oblate.fields.Float(strict=True, **kwargs)#

Representation of a float (float) field.

This class is a subclass of Field and supports the features documented in that class.

ERR_INVALID_DATATYPE#

Error code raised when invalid data type is given in raw data.

ERR_COERCION_FAILED#

Error code raised when strict mode is disabled and given raw value cannot be converted to relevant data type.

Parameters:

strict (bool) – Whether to only allow float data types. If this is set to False, any float-castable value is type casted to float. Defaults to True.

class oblate.fields.Boolean(*, strict=True, true_values=None, false_values=None, **kwargs)#

Representation of a boolean (bool) field.

This class is a subclass of Field and supports the features documented in that class.

TRUE_VALUES#

The true values used when strict validation is disabled.

Type:

Tuple[str, …]

FALSE_VALUES#

The false values used when strict validation is disabled.

Type:

Tuple[str, …]

ERR_INVALID_DATATYPE#

Error code raised when invalid data type is given in raw data.

ERR_COERCION_FAILED#

Error code raised when strict mode is disabled and given raw value cannot be converted to relevant data type.

Parameters:
  • true_values (Sequence[str]) –

    The values to use for true boolean conversion. These are only respected when strict validation is disabled.

    Defaults to TRUE_VALUES if not provided.

  • false_values (Sequence[str]) –

    The values to use for false boolean conversion. These are only respected when strict validation is disabled.

    Defaults to FALSE_VALUES if not provided.