partis.schema.prim.str_prim module#

class StrPrimDeclared(name=None, module=None, module_set=None, doc=None, **kwargs)[source]#

Bases: SchemaPrimDeclared

class StrPrim(name=None, module=None, module_set=None, doc=None, **kwargs)[source]#

Bases: SchemaPrim

Primitive for string values

Parameters:
  • char_case (NoneType | str) –

    Cased characters are converted to given case

    • None (default) : Cased characters are not altered

    • ’lower’ : Cased characters are converted to their lower-case equivalent

    • ’upper’ : Cased characters are converted to their upper-case equivalent

  • strip (NoneType | bool) – Strips leading and trailing white-space if True.

  • pattern (NoneType | str) –

    Validates a string using a regular expression (Python syntax)

    Note

    The pattern is only matched to non-empty strings. See the nonempty argument to only allow string that have at least one character.

  • nonempty (NoneType | bool) – Only non-empty strings are valid if True. If the value is optional, the no-value or a value of None is still considered valid.

  • max_lines (NoneType | int) – Maximum number of lines

  • max_cols (NoneType | int) – Maximum number of columns

  • **kwargs (arguments passed to SchemaPrim) –

validate(val, loc=None, bias=None)[source]#

Validates value against schema definition

Parameters:
Returns:

  • val (object)

  • bias (Bias)

Raises:

SchemaValidationError – If the value is not valid