-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
136 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
import { defineConfig } from 'vitepress' | ||
import { defineConfig } from "vitepress"; | ||
|
||
// https://vitepress.dev/reference/site-config | ||
export default defineConfig({ | ||
title: "Axe API Validator", | ||
description: "Another data validation library", | ||
themeConfig: { | ||
// https://vitepress.dev/reference/default-theme-config | ||
nav: [ | ||
{ text: 'Home', link: '/' }, | ||
{ text: 'Examples', link: '/markdown-examples' } | ||
], | ||
|
||
// nav: [{ text: "GitHub", link: "https://github.com/axe-api/validator" }], | ||
sidebar: [ | ||
{ | ||
text: 'Examples', | ||
text: "Introduction", | ||
items: [ | ||
{ text: "Why?", link: "/why" }, | ||
{ text: "Getting started", link: "/learn" }, | ||
{ text: "Terminology", link: "/terminology" }, | ||
], | ||
}, | ||
{ | ||
text: "Rules", | ||
items: [ | ||
{ text: 'Markdown Examples', link: '/markdown-examples' }, | ||
{ text: 'Runtime API Examples', link: '/api-examples' } | ||
] | ||
} | ||
{ text: "Why?", link: "/xx" }, | ||
{ text: "Getting started", link: "/rr" }, | ||
], | ||
}, | ||
], | ||
|
||
socialLinks: [ | ||
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' } | ||
] | ||
} | ||
}) | ||
{ icon: "github", link: "https://github.com/axe-api/validator" }, | ||
], | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Terminology | ||
|
||
In this section, we are going to explain the basic terminology. | ||
|
||
## Rule | ||
|
||
A rule is a function that takes at least one argument (value) and validates the data. It should return a `true` or `false` value as a return. | ||
|
||
The following type definition is the definition of a rule function. | ||
|
||
```ts | ||
type RuleFunction = (...args: any[]) => boolean; | ||
``` | ||
|
||
The first parameter of a rule function should be the value that will be validated always. | ||
|
||
```ts | ||
export default (value: any): boolean => { | ||
// Return `true` if the `value` is valid. | ||
return true; | ||
}; | ||
``` | ||
|
||
A rule function always might have more parameters if it needs them. For example, if you want to check the minimum string size, the rule function should have to parameter like the following example. | ||
|
||
```ts | ||
export default (value: any, size: any): boolean => { | ||
// Return `true` if the `value` is valid. | ||
return true; | ||
}; | ||
``` | ||
|
||
A rule should be able to execute directly. | ||
|
||
```ts | ||
import { isRequired } from "axe-validator"; | ||
|
||
const result = isRequired("data"); | ||
``` | ||
|
||
## Definition | ||
|
||
The definition means which rule sets will be executed for data. | ||
|
||
It should be an object like the following example: | ||
|
||
```js | ||
const definition = { | ||
email: "required|email", | ||
name: "required|min:1|max:50", | ||
surname: "required|min:1|max:50", | ||
}; | ||
``` | ||
|
||
For each data property, the rule names should be defined. | ||
|
||
The `|` should be used to be able to use multiple rule names at the same time: | ||
|
||
`required|email|alpha` | ||
|
||
All possible rule parameters should be defined between the `:` operator. | ||
|
||
`required|min:1|max:50|between:1:50` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Why? | ||
|
||
Discovering a data validation library that seamlessly combines ease of use, the ability to store validation rules for future use, and robust internationalization (i18n) support is a formidable challenge. While numerous data validation libraries exist, finding one that fulfills all these criteria is often elusive. Some libraries that do meet these requirements are unfortunately no longer actively maintained. | ||
|
||
Axe Validator was born out of the need for a versatile data validation solution that not only simplifies the validation process but also empowers developers with the flexibility to preserve and reuse validation rules. This library aims to bridge the gap by offering a user-friendly experience, ensuring your validation needs are met comprehensively. | ||
|
||
Why choose Axe Validator? It's more than just a data validation tool; it's a commitment to providing a reliable, well-maintained, and feature-rich solution for developers who value simplicity and effectiveness in their projects. | ||
|
||
## Principles | ||
|
||
I decided on some fundamental rules while building this library: | ||
|
||
- Every validation rule should be an independent function. | ||
- Every validation rule should be able to be used separately | ||
- All validation definition should be able to be stored anywhere (database, memory, configuration files, 3rd party API, etc) to be used later. | ||
- All validation rules should be able to be used in different languages. | ||
- Contribution to the rule set should be easy. | ||
- Should be well-documented. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters