Skip to content

Message

Alan Berdinelli edited this page Feb 13, 2024 · 5 revisions

Added in v3.3.1

You can add a custom message when the validation fails without the need for a custom validator function.

const schema = new Schemy({
    name: {
        type: String,
        required: true,
        message: 'Please tell me your name.'
    }
});

schema.validate({});
schema.getValidationErrors(); // => ['Please tell me your name']

Clone this wiki locally