Skip to main content

Failing with a message

When running enforce you can specify a custom failure message to be thrown on failure. This is done via the message modifier. All you need to do is add the message before the rules it refers to.

If a message is provided, it will override the default message of all rules that follow it.

.message('Value must be a number')
.message('Value must be positive')