Open Lefort-Antoine opened 1 year ago
Hi, according marshmallow documentation I would suggest the following way to validate a unique field. In marshmallow>3, the post_load seems to be replaced by the @validates_schema decorator
class Loc(Record):
class Schema(Schema):
pk = fields.String(required=True)
insee = fields.String(missing=None)
@validates_schema
def validate_insee(self, data, **kwargs):
print(len(data["insee"]))
if len(data["insee"]) != 5:
raise ValidationError("Insee must be 5 characters", "insee")](url)
hy
Why this code not generating an error
`from omemdb import Db, Record from omemdb.packages.omarsh import Schema, fields, validate, ValidationError
`
The fonction _insee_validation return an error with "U" as input.
Regards