Field validators as schema methods?
See original GitHub issueOften, validators and preprocessors only apply to a single Schema
, so it may make sense to define them within the Schema
–rather than as separate functions–for better cohesion.
Method names could be passed to __validators__
, et. al, like so:
class UserSchema(Schema):
__validators__ = ['validate_schema']
def validate_schema(self, data):
# ...
Issue Analytics
- State:
- Created 9 years ago
- Comments:37 (37 by maintainers)
Top Results From Across the Web
Mongoose v6.8.0: Validation
Mongoose registers validation as a pre('save') hook on every schema by default ... a field as invalid (causing validation to fail) by using...
Read more >Schema Validation — MongoDB Manual
Schema validation lets you create validation rules for your fields, such as allowed data types and value ranges. MongoDB uses a flexible schema...
Read more >How To Use Schema Validation in MongoDB - DigitalOcean
MongoDB has a feature called schema validation that allows you to apply constraints on your documents' structure. Schema validation is built ...
Read more >Mongoose Schema Types, Validation & Queries Tutorial
Every Schema Types in Mongoose refers to a Collection and organizes the structure of a document. It supports data validation, queries, field ......
Read more >Schema Validation in MongoDB Atlas - Topcoder
Schema validation is a key concept while developing any backend application. Sometimes clients provide inputs which are not according to our ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sloria What about something like this?
It would be a nice convenience.
Awesome! Sorry I didn’t get around to coding this up. Thanks!