示例#1
0
    def validateField(self, validate, v):
        if v is None:
            return

        if 'range' in validate:
            r = validate['range']
            if v < r[0] or v > r[1]:
                raise ValidationException('range', v, r, 'between')

        if 'value' in validate:
            if v != validate['value']:
                raise ValidationException('value', v, validate['value'], '=')

        if 'list' in validate:
            if v not in validate['list']:
                raise ValidationException('list', v, validate['list'], 'in')

        if 'min' in validate:
            if v < validate['min']:
                raise ValidationException('min', v, validate['min'], '>=')
示例#2
0
def validateBin(v):
    if v not in [0, 1]:
        raise ValidationException('bin', v, [0, 1], 'in')
示例#3
0
def validateYear(v):
    if v < 1:
        raise ValidationException('year', v, [1], '>')
示例#4
0
def validateMonth(v):
    if v < 1 or v > 12:
        raise ValidationException('month', v, [1, 12], 'between')
示例#5
0
def validateWeekday(v):
    if v < 1 or v > 7:
        raise ValidationException('weeak day', v, [1, 7], 'between')
示例#6
0
def validateDay(v):
    if v < 1 or v > 31:
        raise ValidationException('day', v, [1, 31], 'between')
示例#7
0
def validateHour(v):
    if v < 0 or v > 24:
        raise ValidationException('hour', v, [0, 24], 'between')