Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
apih committed Aug 10, 2024
1 parent 31090ea commit b9e3c98
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ There are 2 ways to start using `quival` in your project.
Get the script from [jsDelivr CDN page](https://www.jsdelivr.com/package/npm/quival) and include it in your HTML page.

```html
<script src="https://cdn.jsdelivr.net/npm/quival@0.3.x/dist/quival.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/quival@0.4.x/dist/quival.min.js"></script>
```

Extract `Validator` class from `quival` global variable, and you are good to go.
Expand Down Expand Up @@ -83,6 +83,7 @@ Validator.addChecker(

// Prepare arguments
const data = {
refcode: '1bc',
username: 'idea💡',
name: '',
email: 'test',
Expand All @@ -98,6 +99,15 @@ const data = {
};

const rules = {
refcode: [
'required',
function (attribute, value) { // Closure rule
return {
success: /^[a-z]/i.test(value),
message: 'The :attribute field must start with a letter.',
};
},
],
username: ['required', 'ascii', 'min:3'],
name: ['required', 'min:3'],
email: ['required', 'email'],
Expand Down Expand Up @@ -138,6 +148,9 @@ The produced error messages for the code snippet above.

```json
{
"refcode": [
"The refcode field must start with a letter."
],
"username": [
"The username field must only contain single-byte alphanumeric characters and symbols."
],
Expand Down

0 comments on commit b9e3c98

Please sign in to comment.