keystonejs/keystone-classic

Mongoose validator message not displayed in Admin UI

Open

Aperta il 16 mag 2018

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)JavaScript (14.656 star) (2288 fork)batch import
4.x candidatebughelp wanted

Descrizione

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

Guida contributor