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

Custom validation message does not work #32

Open
holyshared opened this issue Dec 10, 2015 · 1 comment
Open

Custom validation message does not work #32

holyshared opened this issue Dec 10, 2015 · 1 comment

Comments

@holyshared
Copy link

When the attribute name and the column name is different, there is a bug that does not use a custom message.

I think the problem is part of the following.
https://github.com/lykmapipo/sails-hook-validation/blob/master/lib/validateCustom.js#L45

model

// User.js
module.exports = {
  tableName: 'users',
  attributes: {
    id: {
      columnName: 'id',
      type: 'integer',
      autoIncrement: true,
      primaryKey: true
    },
    name: {
      columnName: 'user_name', // attribute name !== column name
      type: 'string',
      required: true
    }
  },
  validationMessages: {
    name: {
      string: 'My custom message1',
      required: 'My custom message2'
    }
  }
};

code

User.create({ name: null }).then(function() {

}).catch(function(err) {
  console.log(err.Errors['name']); // undefined!!, I expect the My custom message1, My custom message2
});
@murugesanpalanivel
Copy link

I also have the same issue...anyone know ??please help..

lykmapipo added a commit that referenced this issue Apr 13, 2016
Sails validator do not use column name as property #32
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

2 participants