Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
Ben Nadel at CFUNITED 2008 (Washington, D.C.) with: Rupesh Kumar
Ben Nadel at CFUNITED 2008 (Washington, D.C.) with: Rupesh Kumar@rukumar )

Sequelize - Validation Error: Validation Not Failed

By Ben Nadel on

The other day, I was running some Node.js integration tests when I suddenly started seeing the most confusing Sequelize error: "Validation error: Validation not failed". If you have no idea what is causing this error, the message appears to be contradictory on its face - the validation is failing because the validation did not fail. I was befuddled:


Sequelize validation error: validation not failed. 

To debug this, I started going through the git-log to see what had changed. I discovered that one of my teammates had added a "validate" property to one of the Sequelize Model Schemas:

  • sequelize.define(
  • "Thing",
  • {
  • name: {
  • type: DataTypes.STRING,
  • allowNull: false,
  • validate: {
  • not: [ /\\|\/|:|\?|\*|<|>|"|\||[\x00-\x1F\x7F-\x9F]/g ]
  • }
  • },
  • // ...
  • },
  • {
  • tableName: 'thing'
  • }
  • )

Ahhhh! Notice that there's a validation rule named "not". As in, "Validation NOT failed." So, the error was legitimate; my POST contained data that was matching the Regular Expression defined in the "not" rule. It's just very confusing verbiage (especially when I didn't realize that the Schema had validation rules attached to it).

When I ran across this Sequelize error, I went to Google and Google was no help. So, this post is mostly here to help anyone else who runs into this confusing error and tries to search for some answers.

Reader Comments

Post A Comment

You — Get Out Of My Dreams, Get Into My Comments
Live in the Now
NEW: Some basic markdown formatting is now supported: bold, italic, blockquotes, lists, fenced code-blocks. Read more about markdown syntax »
Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.