chore(validator): add documentation for custom message
This commit is contained in:
parent
aee6a858b4
commit
d96aca8268
1 changed files with 12 additions and 0 deletions
|
|
@ -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.
|
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
|
||||||
|
<validatable-el .validators="${[new Required({}, { getMessage: getCustomMessage })]}"></validatable-el>
|
||||||
|
```
|
||||||
|
|
||||||
### Custom Validators
|
### Custom Validators
|
||||||
|
|
||||||
On top of default validators, application developers can write their own by extending the `Validator` class.
|
On top of default validators, application developers can write their own by extending the `Validator` class.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue