Custom validation of len not working.
See original GitHub issueWhat you are doing?
var Tag = sequelize.define("Tag", {
name: {
type: DataTypes.STRING,
validate: {
len: {
args: [[0,32]],
msg: 'Name too long.'
}
}
}
}
)
What do you expect to happen?
I’m expection an error message like
errors:
[ { message: 'Name too long',
type: 'Validation error',
path: 'name',
...
What is actually happening?
No error is thrown. Nothing gets catched by Sequelize.ValidationError.
Without custom settings it works:
validate: {
len: [0,32]
}
throws a validation error.
sequelize: 3.24.3 node: 6.2.2 maria DB (Server version: 10.1.9-MariaDB Homebrew, Protocol version: 10)
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Custom validation using IF() and Len() - excel - Stack Overflow
I have been trying for a long time but can not get it by trial and error or googling. My best guess is...
Read more >Custom validation doesn't work - MSDN
User-2010772455 posted. Hi,. I've wrote this in a view model: [Required(ErrorMessage = "Page title is very important for SEO, please fill in ...
Read more >Sitecore Forms string length validator not working for other ...
First you need to create an item on /sitecore/system/Settings/Forms/Validations. After you need to create a custom code on Visual studio to ...
Read more >Custom validation not working on latest version - WordPress.org
We are using Contact Form 7 latest version (5.6.1) on our site and when we try to add custom validation using hooks, it...
Read more >Validations & Constraints - Sequelize
You can define your custom validators or use several built-in validators, implemented by validator.js (10.11.0), as shown below. sequelize.
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
@ro70 you have been passing arguments incorrectly to the
args
, it needs to be single array.From Sequelize docs http://docs.sequelizejs.com/en/v3/docs/models-definition/#validations
SSCCE Test
Output
Here’s the code: