Skip to content

Commit

Permalink
Style(form-validations): Fix documentation by markdown linter
Browse files Browse the repository at this point in the history
  • Loading branch information
literat committed Dec 14, 2024
1 parent c1f924c commit 614829a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .remarkignore
Original file line number Diff line number Diff line change
Expand Up @@ -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-*
32 changes: 18 additions & 14 deletions packages/form-validations/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<!--lint disable no-emphasis-as-heading-->
<!-- @see: https://jira.almacareer.tech/browse/DS-1604 -->
<!--lint ignore heading-capitalization-->

# @lmc-eu/spirit-form-validations

> Form validations for Web and Web-Twig packages of the Spirit Design System.
Expand Down Expand Up @@ -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
});
};
```

Expand Down Expand Up @@ -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 |
| --------- | ----------------------------------------------------------------------------------------------------- | ------------------------------- |
Expand All @@ -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'));
Expand All @@ -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.

Expand All @@ -157,7 +161,7 @@ Now you can assign it to your inputs like this
<input type="text" class="form-control" data-spirit-my-range="10,30" />
```

### Add custom error messages
### Add Custom Error Messages

```html
<input required data-spirit-required-message="My custom message" />
Expand Down Expand Up @@ -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)**

Expand Down

0 comments on commit 614829a

Please sign in to comment.