From d96aca8268aee3a74a086f7cbf627ed1f8d13c44 Mon Sep 17 00:00:00 2001 From: Thomas Rutten Date: Fri, 7 Feb 2020 11:10:34 +0100 Subject: [PATCH] chore(validator): add documentation for custom message --- packages/validate/stories/Overview.stories.mdx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/validate/stories/Overview.stories.mdx b/packages/validate/stories/Overview.stories.mdx index fc6d3e02e..df6e931da 100644 --- a/packages/validate/stories/Overview.stories.mdx +++ b/packages/validate/stories/Overview.stories.mdx @@ -83,6 +83,18 @@ All validators return `false` if the required validity state is met. All validators are considered self explanatory due to their explicit namings. +You can implement your own custom message for a default validator. Pass a getMessage function via the options in the construtor. + +```js +function getCustomMessage(data) { + return `${data.name} is a required field`; +} +``` + +```html + +``` + ### Custom Validators On top of default validators, application developers can write their own by extending the `Validator` class.