emmett icon indicating copy to clipboard operation
emmett copied to clipboard

introduce model validators

Open gi0baro opened this issue 3 years ago • 0 comments

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 ).

gi0baro avatar May 25 '22 10:05 gi0baro