Single value constraint

class pyasn1.type.constraint.SingleValueConstraint(*values)

Create a SingleValueConstraint object.

The SingleValueConstraint satisfies any value that is present in the set of permitted values.

Objects of this type are iterable (emitting constraint values) and can act as operands for some arithmetic operations e.g. addition and subtraction. The latter can be used for combining multiple SingleValueConstraint objects into one.

The SingleValueConstraint object can be applied to any ASN.1 type.

Parameters

*values (int) – Full set of values permitted by this constraint object.

Examples

class DivisorOfSix(Integer):
    '''
    ASN.1 specification:

    Divisor-Of-6 ::= INTEGER (1 | 2 | 3 | 6)
    '''
    subtypeSpec = SingleValueConstraint(1, 2, 3, 6)

# this will succeed
divisor_of_six = DivisorOfSix(1)

# this will raise ValueConstraintError
divisor_of_six = DivisorOfSix(7)