def __init__(self, source): super(MyEditor, self).__init__(source, self.fields) self.name.validate(lambda v: validator.to_string(v, strip=True). not_empty().to_string()) self.age.validate(lambda v: validator.to_int(v).lesser_than(50). greater_than(0).to_int())
def __init__(self, target): """Initialization Create a ``editor.property`` for each ``self.fields`` of the target object In: - ``target`` -- the object to edit """ super(FormEditor, self).__init__(target, self.fields) # Set the conversion and validation rules on the properties self.age.validate(validator.to_int().lesser_than(50).greater_than(10)) self.area.validate(validator.to_string(strip=True).not_empty().match(r'^[a-d]+$')) # A property can also be manually created self.file = editor.Property().validate(self.validate_file) # An editor can have more properties than the attributes of the target object self.confirm = editor.Property('').validate(self.validate_confirm)
def __init__(self, target): """Initialization Create a ``editor.property`` for each ``self.fields`` of the target object In: - ``target`` -- the object to edit """ super(FormEditor, self).__init__(target, self.fields) # Set the conversion and validation rules on the properties self.age.validate(validator.to_int().lesser_than(50).greater_than(10)) self.area.validate( validator.to_string(strip=True).not_empty().match(r'^[a-d]+$')) # A property can also be manually created self.file = editor.Property().validate(self.validate_file) # An editor can have more properties than the attributes of the target object self.confirm = editor.Property('').validate(self.validate_confirm)
def validate_nb_cards(self, value): if value: return nagare_validator.to_int(value) return value
def __init__(self, source): super(MyEditor, self).__init__(source, self.fields) self.name.validate(lambda v: validator.to_string(v, strip=True).not_empty().to_string()) self.age.validate(lambda v: validator.to_int(v).lesser_than(50).greater_than(0).to_int())