firecrown.descriptors.TypeString#

class firecrown.descriptors.TypeString(minsize=None, maxsize=None, predicate=None)[source]#

Bases: object

String 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 (None | int) –

  • maxsize (None | 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 (None | str) –

Return type:

None

__set_name__(_, name)[source]#

Create the name of the private instance variable that will hold the value.

Parameters:

name (str) –

Return type:

None

validate(value)[source]#

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.

Parameters:

value (None | str) –

Return type:

None