示例#1
0
 class MyRecord(Record):
     id = Field(
         type=int,
         nullable=True,
         default=100,
         check=lambda v: 0 < v < 10,
     )
示例#2
0
 class MyRecord(Record):
     id = Field(
         type=text_type,
         nullable=True,
         default='lower',
         coerce=lambda v: v.upper(),
     )
示例#3
0
 class MyRecord(Record):
     id = Field(
         type=int,
         check=SourceCodeTemplate(
             '$single_digit({})',
             single_digit=lambda v: 0 <= v < 10,
         ),
     )
示例#4
0
 class MyRecord(Record):  # pylint: disable=unused-variable
     id = Field(
         type=text_type,
         check=SourceCodeTemplate(
             '$isupper({0})',
             isupper=lambda s: s == s.upper(),
         ),
     )
示例#5
0
 class MyRecord(Record):  # pylint: disable=unused-variable
     id = Field(
         type=text_type,
         coerce=SourceCodeTemplate(
             '$upper({},{})',
             upper=lambda s: s.upper(),
         ),
     )
示例#6
0
 class MyRecord(Record):
     id = Field(
         type=text_type,
         coerce=SourceCodeTemplate(
             '$upper({})',
             upper=lambda s: s.upper(),
         ),
     )
示例#7
0
 class MyRecord(Record):
     id = Field(
         type=int,
         check=SingleDigit(),
     )
示例#8
0
 class MyRecord(Record):
     v = dict_of(Field(int), Field(int))
示例#9
0
 class MyRecord(Record):
     v = set_of(Field(int))
示例#10
0
 class MyRecord(Record):
     id = Field(
         type=text_type,
         coerce='{}.upper()',
     )
示例#11
0
 class MyRecord(Record):
     id = Field(
         type=int,
         coerce=coercion,
     )
示例#12
0
 class MyRecord(Record):
     id = Field(
         type=text_type,
         coerce=lambda s: s.upper(),
     )
示例#13
0
 class MyRecord(Record):
     id = Field(
         type=int,
         coerce=lambda v: v + 10,
         check=lambda v: 0 <= v < 10,
     )
示例#14
0
 class MyRecord(Record):
     id = Field(
         type=text_type,
         coerce=lambda s: None,
         nullable=True,
     )
示例#15
0
 class MyRecord(Record):
     id = Field(
         type=text_type,
         check=boom,
     )
示例#16
0
 class MyRecord(Record):
     id = Field(
         type=text_type,
         check=re.compile(r'brac').search,
     )
示例#17
0
 class MyRecord(Record):
     id = Field(
         type=text_type,
         check=lambda s: s == 'valid',
     )
示例#18
0
 class MyRecord(Record):
     id = Field(
         type=text_type,
         check=not_none,
     )
示例#19
0
 class MyRecord(Record):
     id = Field(
         type=text_type,
         nullable=True,
         check=not_none,
     )
示例#20
0
 class MyRecord(Record):
     id = Field(
         type=text_type,
         coerce=lambda v: None,
     )
示例#21
0
 class MyRecord(Record):
     id = Field(
         type=MyClass,
         nullable=True,
         default=MyClass(10),
     )
示例#22
0
 class MyRecord(Record):  # pylint: disable=unused-variable
     id = Field(
         type=text_type,
         coerce=0,
     )
示例#23
0
 class MyRecord(Record):
     id = Field(
         type=int,
         check='0 <= {} < 10',
     )
示例#24
0
 class MyRecord(Record):
     id = Field(
         type=text_type,
         coerce=Upper(),
     )
示例#25
0
 class MyRecord(Record):  # pylint: disable=unused-variable
     id = Field(
         type=text_type,
         check='len({0}) == 3',
     )
示例#26
0
 class MyRecord(Record):  # pylint: disable=unused-variable
     id = Field(
         type=text_type,
         coerce='{}.upper({})',
     )
示例#27
0
 class MyRecord(Record):  # pylint: disable=unused-variable
     id = Field(
         type=text_type,
         check='{} == {}.upper()',
     )
示例#28
0
 class MyRecord(Record):
     id = Field(int)
示例#29
0
 class MyRecord(Record):
     v = pair_of(Field(int))