Model validation doesn't report the model it fails for
See original GitHub issueVersion: 2.1.3
Given a model with required name
and description
attributes, I’m seeing the following validation errors:
ValidationError: name: is a required property, description: is a required property
at Function.createValidationError (node_modules/objection/lib/model/Model.js:357:12)
at parseValidationError (node_modules/objection/lib/model/AjvValidator.js:189:21)
at AjvValidator.validate (node_modules/objection/lib/model/AjvValidator.js:78:19)
at validate (node_modules/objection/lib/model/modelValidate.js:35:20)
at Object.$validate (node_modules/objection/lib/model/Model.js:93:12)
at GraphInsertAction._insert (node_modules/objection/lib/queryBuilder/graph/insert/GraphInsertAction.js:177:16)
at GraphInsertAction._insertBatch (node_modules/objection/lib/queryBuilder/graph/insert/GraphInsertAction.js:48:16)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Shouldn’t this error report which model it fails for? Seems like it’d be easier if multiple models are involved (test setup for example) to determine which one is the offending one, without requiring further debugging.
I’m imagining something like this for a model named Task
:
ValidationError (Task): name: is a required property, description: is a required property
at Function.createValidationError (node_modules/objection/lib/model/Model.js:357:12)
at parseValidationError (node_modules/objection/lib/model/AjvValidator.js:189:21)
at AjvValidator.validate (node_modules/objection/lib/model/AjvValidator.js:78:19)
at validate (node_modules/objection/lib/model/modelValidate.js:35:20)
at Object.$validate (node_modules/objection/lib/model/Model.js:93:12)
at GraphInsertAction._insert (node_modules/objection/lib/queryBuilder/graph/insert/GraphInsertAction.js:177:16)
at GraphInsertAction._insertBatch (node_modules/objection/lib/queryBuilder/graph/insert/GraphInsertAction.js:48:16)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9
Top Results From Across the Web
Resolve model validation failed errors in CloudFormation - AWS
When I create a resource with AWS CloudFormation, I receive a "Model Validation Failed" error in my stack events.
Read more >Model validation in ASP.NET Core MVC | Microsoft Learn
Model validation occurs after model binding and reports errors where data doesn't conform to business rules. For example, a 0 is entered in ......
Read more >Reporting Model Validation Errors in ASP.NET Core 2.0
During a model validation failure event, an instance of ValidationProblemDetails is filled in and sent out with Content-Type header set to ...
Read more >BUG: validation doesn't run in model.save() if model ... - GitHub
This issue seems to be mitigated by calling the validateSync() function, but even so, it should NEVER write data failing to pass validation...
Read more >Change the default error message in the model state binder ...
Model state represents errors that come from two subsystems: model binding and model validation. Errors that originate from model binding ...
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 Free
Top 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
ValidationError and NotFoundError now have a
modelClass
property.@devinivy I fixed the issue and released a new version. Sorry about that.