Permitted alphabet constraint

class pyasn1.type.constraint.PermittedAlphabetConstraint(*alphabet)

Create a PermittedAlphabetConstraint object.

The PermittedAlphabetConstraint satisfies any character string for as long as all its characters are present in the set of permitted characters.

The PermittedAlphabetConstraint object can only be applied to the character ASN.1 types such as IA5String.

Parameters:*alphabet (str) – Full set of characters permitted by this constraint object.


class BooleanValue(IA5String):
    ASN.1 specification:

    BooleanValue ::= IA5String (FROM ('T' | 'F'))
    subtypeSpec = PermittedAlphabetConstraint('T', 'F')

# this will succeed
truth = BooleanValue('T')
truth = BooleanValue('TF')

# this will raise ValueConstraintError
garbage = BooleanValue('TAF')