Skip to content
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

Not adding custom messages in Sails v1.0.0-36 #55

Open
LucasMcL opened this issue Sep 28, 2017 · 4 comments
Open

Not adding custom messages in Sails v1.0.0-36 #55

LucasMcL opened this issue Sep 28, 2017 · 4 comments

Comments

@LucasMcL
Copy link

LucasMcL commented Sep 28, 2017

Hi. I can't seem to get this hook to work in Sails v1.0.0-36. Here's what I have.

Model EstablishmentClue

module.exports = {

  attributes: {

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

  ...

  },

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

};

In sails console:

sails> EstablishmentClue.create({}).exec(console.log);
Error (E_UNKNOWN) :: Encountered an unexpected error
    at new WLError (/Users/Lucas/CompuDharma/treasuretown/treasuretown_web/node_modules/sails-hook-validation/node_modules/waterline/lib/waterline/error/WLError.js:26:15)
    at Object.module.exports.patch (/Users/Lucas/CompuDharma/treasuretown/treasuretown_web/node_modules/sails-hook-validation/lib/WLValidationError.js:8:13)
    at /Users/Lucas/CompuDharma/treasuretown/treasuretown_web/node_modules/sails-hook-validation/lib/create.js:66:48
    at _.extend._WLModel (/Users/Lucas/CompuDharma/treasuretown/treasuretown_web/node_modules/waterline/lib/waterline/methods/create.js:155:20)
    at parley (/Users/Lucas/CompuDharma/treasuretown/treasuretown_web/node_modules/parley/lib/parley.js:111:5)
    at newConstructor.create (/Users/Lucas/CompuDharma/treasuretown/treasuretown_web/node_modules/waterline/lib/waterline/methods/create.js:130:10)
    at newConstructor.create (/Users/Lucas/CompuDharma/treasuretown/treasuretown_web/node_modules/sails-hook-validation/lib/create.js:47:14)
    at module.exports.Deferred.exec (/Users/Lucas/CompuDharma/treasuretown/treasuretown_web/node_modules/sails-hook-validation/node_modules/waterline/lib/waterline/query/deferred.js:477:16)
    at repl:1:30
    at ContextifyScript.Script.runInThisContext (vm.js:44:33)
    at REPLServer.defaultEval (repl.js:239:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:433:10)
    at emitOne (events.js:120:20)
    at REPLServer.emit (events.js:210:7)
    at REPLServer.Interface._onLine (readline.js:278:10)
    at REPLServer.Interface._line (readline.js:625:8)
    at REPLServer.Interface._ttyWrite (readline.js:904:14)
    at REPLServer.self._ttyWrite (repl.js:502:7)
    at ReadStream.onkeypress (readline.js:157:10)
    at emitTwo (events.js:125:13)
    at ReadStream.emit (events.js:213:7)
    at emitKeys (internal/readline.js:417:14)
    at emitKeys.next (<anonymous>)
    at ReadStream.onData (readline.js:1005:36)
    at emitOne (events.js:115:13)
    at ReadStream.emit (events.js:210:7)
    at addChunk (_stream_readable.js:250:12)
    at readableAddChunk (_stream_readable.js:237:11)
    at ReadStream.Readable.push (_stream_readable.js:195:10)
    at TTY.onread (net.js:586:20)

When I log error.toJSON() I get this:

{ error: 'E_UNKNOWN',
  status: 500,
  summary: 'Encountered an unexpected error',
  Errors: undefined }

Any thoughts on why the custom error messages aren't attaching?

@ghost
Copy link

ghost commented Sep 30, 2017

I have the same issue as well. Also using version v1 of Sails.

@izanagi1995
Copy link

This is because in WLValidationError.js, the function toJSON/toPOJO is never called

@izanagi1995
Copy link

asJSON[errorKey] = this.Errors; this.Errors is not defined in WLValidationError.js

@prof-jagpreet
Copy link

I am having same issue. I think its a long pending issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants