[Python] Getting Validation Errors in Marshmallow schema

Discussão em 'Python' iniciado por Stack, Outubro 6, 2024.

  1. Stack

    Stack Membro Participativo

    I am using the Marshmallow library for data validation and serialization. I am allowing None values for some fields in my schema, but I keep getting validation errors even though I have set allow_none = True.

    class MySchema(Schema):
    name = fields.String(required=True, allow_none=True)
    age = fields.Integer(allow_none=True)

    schema = MySchema()

    data = {"age": None}
    result = schema.load(data)
    print(result)



    Why is it failing validation for the 'name' field even though allow_none = True ?

    Continue reading...

Compartilhe esta Página