firecrown.descriptors ===================== .. py:module:: firecrown.descriptors .. autoapi-nested-parse:: Type validation as used in connectors. Validators are created using the constructor for each class. Access to the data done through the object name, not through any named function. Setting the data is validated with the class's `validate` function; the user does not need to call any special functions. Validators are intended for use in class definitions. An example is a class that has an attribute `x` that is required to be a float in the range [1.0, 3.0], but is optional and has a default value of None: .. code:: python class SampleValidatedThing: x = TypeFloat(1.0, 3.0, allow_none=True) def __init__(self): self.x = None Classes ------- .. autoapisummary:: firecrown.descriptors.TypeFloat firecrown.descriptors.TypeString Module Contents --------------- .. py:class:: TypeFloat(minvalue = None, maxvalue = None, allow_none = False) Floating point number attribute descriptor. .. py:attribute:: minvalue :value: None .. py:attribute:: maxvalue :value: None .. py:attribute:: allow_none :value: False .. py:method:: validate(value) Run all validators on this value. Raise an exception if the provided `value` does not meet all of the required conditions enforced by this validator. .. py:method:: __set_name__(_, name) Create the name of the private instance variable that will hold the value. :param name: The name of the private instance variable to be created. .. py:method:: __get__(obj, objtype=None) Accessor method, which reads controlled value. This is invoked whenever the validated variable is read. :param obj: The object that contains the validated variable. :param objtype: The type of the object that contains the validated variable. .. py:method:: __set__(obj, value) Setter for the validated variable. This function invokes the `validate` method of the derived class. :param obj: The object that contains the validated variable. :param value: The new value of the validated variable. .. py:class:: TypeString(minsize = None, maxsize = None, predicate = None) String attribute descriptor. :class:`TypeString` provides several different means of validation of the controlled string attribute, all of which are optional. .. py:attribute:: minsize :value: None .. py:attribute:: maxsize :value: None .. py:attribute:: predicate :value: None .. py:method:: validate(value) Run all validators on this value. Raise an exception if the provided `value` does not meet all of the required conditions enforced by this validator. :param value: The value to be validated. .. py:method:: __set_name__(_, name) Create the name of the private instance variable that will hold the value. :param name: The name of the private instance variable to be created. .. py:method:: __get__(obj, objtype=None) Accessor method, which reads controlled value. This is invoked whenever the validated variable is read. :param obj: The object that contains the validated variable. :param objtype: The type of the object that contains the validated variable. .. py:method:: __set__(obj, value) Setter for the validated variable. This function invokes the `validate` method of the derived class. :param obj: The object that contains the validated variable. :param value: The new value of the validated variable.