expyct.string module

class expyct.string.String(*args, **kwargs)

Bases: expyct.collection.Contains, expyct.collection.Length, expyct.base.Satisfies, expyct.base.Equals[str], expyct.base.Instance, expyct.base.Optional, expyct.base.MapBefore, expyct.base.BaseMatcher, str

Match any object that is a string.

Parameters
  • map_before – apply function before checking equality

  • optional – whether None is allowed [default: False]

  • type – type of object must equal to given type

  • instance_of – object must be an instance of given type

  • equals – object must equal exactly. This is useful together with map_before to check a value after applying a function

  • satisfies – object must satisfy predicate

  • length – object length must be exactly

  • min_length – object length must be at least

  • max_length – object length must be at most

  • non_empty – object must have at least one member [default: False]

  • superset_of – collection of which the object must be a superset

  • subset_of – collection of which the object must be a subset

  • starts_with – string must start with given

  • ends_with – string must end with given

  • regex – string must fully match predicate

  • ignore_case – whether to ignore case for starts_with, ends_with,

  • [default (equality and regex matching) – False]

expyct.string.ANY_ALPHANUMERIC_STRING = expyct.Instance(non_empty=False, regex=re.compile('[a-zA-Z0-9_]*'), ignore_case=False)

Any string only consisting of the characters a-z, A-Z, 0-9 and _

expyct.string.ANY_NONEMPTY_STRING = expyct.Instance(non_empty=True, ignore_case=False)

Any string with length more than 0

expyct.string.ANY_STRING = expyct.Instance(non_empty=False, ignore_case=False)

Any string

expyct.string.ANY_UUID = expyct.Instance(non_empty=False, regex=re.compile('[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}'), ignore_case=False)

Any string in the form of a UUID