From 614829a854722ac6fd68bf3523099359268337f8 Mon Sep 17 00:00:00 2001 From: literat Date: Sat, 14 Dec 2024 18:14:54 +0100 Subject: [PATCH] Style(form-validations): Fix documentation by markdown linter --- .remarkignore | 6 +++--- packages/form-validations/README.md | 32 ++++++++++++++++------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/.remarkignore b/.remarkignore index 3ca7ea0fc5..8caee49792 100644 --- a/.remarkignore +++ b/.remarkignore @@ -6,8 +6,8 @@ dist build .github -# Temporary disabled packages -# we will fix them incrementally -form-validations # Codemods transforms directory transforms + +# Fix case of the files +MIGRATION-* diff --git a/packages/form-validations/README.md b/packages/form-validations/README.md index 71ead35dc7..110697089f 100644 --- a/packages/form-validations/README.md +++ b/packages/form-validations/README.md @@ -1,3 +1,7 @@ + + + + # @lmc-eu/spirit-form-validations > Form validations for Web and Web-Twig packages of the Spirit Design System. @@ -40,19 +44,19 @@ Now create a form: … and validate it: -``` +```javascript window.onload = () => { - const form = document.getElementById("form1"); + const form = document.getElementById('form1'); - // create the FormValidations instance - const formValidations = new FormValidations(form); + // create the FormValidations instance + const formValidations = new FormValidations(form); - form.addEventListener('submit', function (event) { - event.preventDefault(); + form.addEventListener('submit', function (event) { + event.preventDefault(); - // check if the form is valid - const valid = formValidations.validate(); // returns true or false - }); + // check if the form is valid + const valid = formValidations.validate(); // returns true or false + }); }; ``` @@ -87,7 +91,7 @@ const defaultConfig = { - **live** - A boolean value indicating whether FormValidations should validate as you type, default is `true` -## Built-in validators +## Built-in Validators | Name | Usage | Description | | --------- | ----------------------------------------------------------------------------------------------------- | ------------------------------- | @@ -108,7 +112,7 @@ const defaultConfig = { FormValidations.addValidator(nameOrElem, handler, errorMessage, priority, halt); ``` -### Add a custom validator to a field +### Add a Custom Validator to a Field ```javascript var formValidations = new FormValidations(document.getElementById('form1')); @@ -130,7 +134,7 @@ FormValidations.addElementValidator( ); ``` -### Add a global custom validator +### Add a Global Custom Validator A validator to check if the input value is within a specified range. @@ -157,7 +161,7 @@ Now you can assign it to your inputs like this ``` -### Add custom error messages +### Add Custom Error Messages ```html @@ -218,7 +222,7 @@ _Set the current locale globally_ | `locale` | — | ✓ | The corresponding locale | | `messages` | — | ✓ | Object containing validator names as keys and error texts as values | -### Custom validators +### Custom Validators **FormValidations.addElementValidator(elem, fn, message, priority, halt)**