emmett
emmett copied to clipboard
introduce model validators
Specifically, support validation functions in models which would operate on the entire records instead of a single field.
Ideal usage should look like this:
class Stuff(Model):
foo = Field.string()
bar = Field.string()
@validator(pre=True)
def _validate_row_before_fields_validations(self, row):
...
@validator()
def _validate_row_after_fields_validations(self, row):
...
This ideally also solves the actual hackery behind the unique field validator, as with a record validator there's no need to recognize/store primary fields somewhere (see #428 ).