New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
instance.validate does not do typeValidation #11266
Comments
Actually, I have just checked the docs, what is says for
So apparently I think your example behaves like the docs say it should. However, I agree this might be a valid change... |
I think the behaviour as it stands is problematic because all the write functions in model.js (save, update, upsert, bulkCreate) start by doing instance.validate if options.validate is true. It should therefore be possible to skip a lot of code if type validation fails, instead of finding out much later that the query is invalid. |
I have come across another problem relating to this issue. If you are doing |
This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂 |
This is still an issue with version 6.9.0 |
What are you doing?
To Reproduce
Run the code above
What do you expect to happen?
When creating a Sequelize instance with typeValidation turned on, I expect that types are validated when calling the validate method on an instance. I expect output from the above code
to be two SequelizeValidationErrors - one saying '"bar" is not a valid integer' and one saying '"baz" is not a valid integer'.
What is actually happening?
Only one error way thrown - the one saying '"baz" is not a valid integer'.
This is because the InstanceValidator does not do anything with typeValidation, while the QueryGenerator (which isn't being used in the build/validate process) does.
Environment
Dialect:
Dialect library version: 10.5
Database version: 10
Sequelize version: 5.10.0
Node Version: 10.16.0
OS: Ubuntu 16.04
Tested with latest release:
The text was updated successfully, but these errors were encountered: