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.

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)