Value range constraint

class pyasn1.type.constraint.ValueRangeConstraint(start, end)

Create a ValueRangeConstraint object.

The ValueRangeConstraint satisfies any value that falls in the range of permitted values.

The ValueRangeConstraint object can only be applied to Integer and Real types.

Parameters:
  • start (int) – Minimum permitted value in the range (inclusive)
  • end (int) – Maximum permitted value in the range (inclusive)

Examples

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

    TeenAgeYears ::= INTEGER (13 .. 19)
    '''
    subtypeSpec = ValueRangeConstraint(13, 19)

# this will succeed
teen_year = TeenAgeYears(18)

# this will raise ValueConstraintError
teen_year = TeenAgeYears(20)