.withMessage()
must immediately follow a validation or sanitizer method that sets an internal validator, such as .isEmail()
, .isLength()
, .exists()
, etc. If you call .withMessage()
directly after .escape()
, .trim()
, .normalizeEmail()
, or similar methods that are not validators, you'll get this error1.