keystonejs/keystone-classic
View on GitHubMongoose validator message not displayed in Admin UI
Open
#4634 opened on May 16, 2018
4.x candidatebughelp wanted
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 |