keystone-classic icon indicating copy to clipboard operation
keystone-classic copied to clipboard

Mongoose validator message not displayed in Admin UI

Open alsoicode opened this issue 6 years ago • 0 comments

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

alsoicode avatar May 16 '18 01:05 alsoicode