firecrown.descriptors.TypeString#
- class firecrown.descriptors.TypeString(minsize=None, maxsize=None, predicate=None)[source]#
Bases:
objectString attribute descriptor.
TypeString provides several different means of validation of the controlled string attribute, all of which are optional.
minsize provides a required minimum length for the string maxsize provides a required maximum length for the string predicate allows specification of a function that must return true
when a string is provided to allow use of that string.
- Parameters:
minsize (
Optional[int]) –maxsize (
Optional[int]) –predicate (
Optional[Callable[[str],bool]]) –
Public Methods:
__init__([minsize, maxsize, predicate])Initialize the TypeString object.
validate(value)Run all validators on this value.
__set_name__(_, name)Create the name of the private instance variable that will hold the value.
__get__(obj[, objtype])Accessor method, which reads controlled value.
__set__(obj, value)Setter for the validated variable.
- __get__(obj, objtype=None)[source]#
Accessor method, which reads controlled value.
This is invoked whenever the validated variable is read.
- Return type:
str
- __set__(obj, value)[source]#
Setter for the validated variable.
This function invokes the validate method of the derived class.
- Parameters:
value (
Optional[str]) –- Return type:
None