keystonejs/keystone-classic

Mongoose validator message not displayed in Admin UI

Open

#4,634 opened on May 16, 2018

View on GitHub
 (0 comments) (0 reactions) (0 assignees)JavaScript (2,288 forks)batch import
4.x candidatebughelp wanted

Repository metrics

Stars
 (14,656 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Expected behavior

When using a custom validator on a field, the validation message should be surfaced in the admin UI.

Actual/Current behavior

The message value is not displayed. Instead, ValidationError: [model name] validation failed is displayed, which does not indicate which field the error corresponds to.

Steps to reproduce the actual/current behavior

Create a Mongoose model and add a validate object to a field. Example:

[YourModel].add({
  phone: {
    type: Types.Text,
    required: true,
    initial: true,
    validate: {
      validator: function(value: any) {
        return /\d{3}-\d{3}-\d{4}/.test(value);
      },
      message: '{VALUE} is not a valid phone number',
    },
  }
});

Environment

Software Version
Keystone 4, Beta 8
Node 8.11.1
Mongoose 5.1.1

Contributor guide