You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using flask-marshmallow for the first time and the lib looks great but I don't get what I am supposed to do to get an error when I try to validate an element with a missing field.
Here's a simplified version of the code :
from flask import Flask
from flask_marshmallow import Marshmallow
app = Flask(__name__)
ma = Marshmallow(app)
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy(app)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String, nullable=False)
class UserSchema(ma.Schema):
class Meta:
fields = ("id", "name")
user_schema = UserSchema()
print(user_schema.validate({}, partial=False))
This outputs {} while I would expect it to return an object listing errors.
(Just in case, I also tried with partial=True and partial=('id',), and I also tried to set the partial values at different places (schema definition and schema instanciation) but I get the same result)
Could you please advice on what I am doing wrong ?
Hi !
I am using flask-marshmallow for the first time and the lib looks great but I don't get what I am supposed to do to get an error when I try to validate an element with a missing field.
Here's a simplified version of the code :
This outputs
{}
while I would expect it to return an object listing errors.(Just in case, I also tried with
partial=True
andpartial=('id',)
, and I also tried to set thepartial
values at different places (schema definition and schema instanciation) but I get the same result)Could you please advice on what I am doing wrong ?
For information, here are the versions I use :
marshmallow==3.0.0rc8
marshmallow-sqlalchemy==0.17.0
flask-marshmallow==0.10.1
Flask-SQLAlchemy==2.4.0
SQLAlchemy==1.3.6
The text was updated successfully, but these errors were encountered: