1

I am having an issue getting validation error messages to attach to the error object in sails v1.0. I am using the sails-hook-validate module.

User model:

module.exports = {

  attributes: {

   name: {
    type: 'string',
    required: true,
   }

  },

  validationMessages: {
   name: {
    required: 'Name is required'
   },
  },

};

Running User.create in the sails console:

sails> User.create({}).exec(err => console.log(err.toJSON()));
{ error: 'E_UNKNOWN',
  status: 500,
  summary: 'Encountered an unexpected error',
  Errors: undefined }

It appears sails-hook-validate is modifying the error object in some way, but it doesn't seem to be adding my custom error message in any way. Does anybody know how to get sails-hook-validate to work in Sails v1.0?

Lucas
  • 23
  • 4

2 Answers2

0

Sails v1 dramatically changed how validation errors are formatted and sails-hook-validate hasn't been updated to handle Sails v1 yet.

0

Sails-hook-validate is a third party hook and I dont think its been updated to work with Sails V1. As @jeffery mentioned the structure of validation errors did change slightly in Sails V1 but there could be other changes that are effecting this hook.

Raqem
  • 424
  • 2
  • 9