keystonejs/keystone-classic

Mongoose validator message not displayed in Admin UI

Aberta

#4.634 aberto em 16 de mai. de 2018

 (0 comentário) (0 reação) (0 responsável)JavaScript (2.288 forks)batch import
4.x candidatebughelp wanted

Métricas do repositório

Stars
 (14.656 estrelas)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 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

Guia do colaborador