question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why aren't custom error_messages supported for the `load` and `loads` methods on Schema?

See original GitHub issue

Title.

Why does this code only support dump and dumps?

Validation happens on load and loads too, so presumably it makes sense for me to able to overload those messages with the same class variable too, no?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sloriacommented, Sep 13, 2019

Ah thanks. Fixed

1reaction
sloriacommented, Sep 13, 2019

@acnebs

“Required” validation is field-level, not schema-level, so you need to set the default error messages on Field.

from marshmallow import Schema, fields

fields.Field.default_error_messages["required"] = "boom!"


class ArtistSchema(Schema):
    name = fields.Str(required=True)


print(ArtistSchema().validate({}))  # {'name': ['boom!']}

@lafrech The docs appear correct. Am I missing something?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom Error Messages with Mongoose - Stack Overflow
So I wanted to do something similar: var emailVerificationTokenSchema = mongoose.Schema({ email: {type: String, required: ...
Read more >
Ajv: Another JSON Schema Validator - ajv - npm
Asynchronous version of compile method that loads missing remote schemas using asynchronous function in options.loadSchema . This function returns a Promise ...
Read more >
Changelog — marshmallow 3.19.0 documentation
This reverts a change introduced in 3.12.0 that causes issues when field names conflict with Schema attributes or methods. Fields s are still...
Read more >
Common issues and resolutions for Power Apps
A list of common issues and resolutions within Power Apps.
Read more >
marshmallow - Read the Docs
load () (and its JSON-decoding counterpart, Schema.loads()) returns a dictionary of validation errors as the second element of its return value. Some fields, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found