Constraints exclusion

class pyasn1.type.constraint.ConstraintsExclusion(constraint)

Create a ConstraintsExclusion logic operator object.

The ConstraintsExclusion logic operator succeeds when the value does not satisfy the operand constraint.

The ConstraintsExclusion object can be applied to any constraint and logic operator object.

Parameters:constraint – Constraint or logic operator object.


class Lipogramme(IA5STRING):
    ASN.1 specification:

    Lipogramme ::=
        IA5String (FROM (ALL EXCEPT ("e"|"E")))
    subtypeSpec = ConstraintsExclusion(
        PermittedAlphabetConstraint('e', 'E')

# this will succeed
lipogramme = Lipogramme('A work of fiction?')

# this will raise ValueConstraintError
lipogramme = Lipogramme('Eel')


The above example involving PermittedAlphabetConstraint might not work due to the way how PermittedAlphabetConstraint works. The other constraints might work with ConstraintsExclusion though.