Validators not being applied

Hello there,

I have a model that I’m adding some validators following the docs from FA and Sequelize. Here’s an example:

The problem is that this validation does not run. I try to fill in the field with a string that is not an e-mail and I’m able to save the model.
The only validator that applies correctly is the len. I can’t make any other work.

Am I doing something wrong here?

This is the version I’m running: “forest-express-sequelize”: “^7.12.3”,

Hello @nathanqueija,

Looking at the latest sequelize documentation validate: { isEmail: true } should work. What version of sequelize are you using ? (The issue should be on there side)

In the meanwhile you can try to use the is validator with a regex from https://emailregex.com/.

validate: { is: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ }

Tell me if it works for you !

Kind regards,
Morgan

My sequelize version is "sequelize": "^5.22.4"

Looking at the related sequelize v5 documentation it should work.

Can you try the alternative I gave you ? :pray:

Regards,
Morgan

The RegEx works! But the sequelize validators don’t:confused: Would be nice to know why. Is this something you can reproduce?

It works fine for me I got the error message: Users creation failed: Validation error: Validation isEmail on email failed

I tested it with the following config.

sequelize 5.15.2
forest-express-sequelize 8.4.4

I presume sequelize have an issue on the specific version you use. I don’t see any open issue on their github.

Kind regards,
Morgan