diff --git a/404.html b/404.html index 59264cc..46a58b7 100644 --- a/404.html +++ b/404.html @@ -15,7 +15,7 @@
Skip to content

404

PAGE NOT FOUND

But if you don't change your direction, and if you keep looking, you may end up where you are heading.

Released under the MIT License.

- + \ No newline at end of file diff --git a/api-examples.html b/api-examples.html index 762a36f..bcab733 100644 --- a/api-examples.html +++ b/api-examples.html @@ -115,7 +115,7 @@ }

Page Frontmatter

{
   "outline": "deep"
 }

More

Check out the documentation for the full list of runtime APIs.

- + \ No newline at end of file diff --git a/assets/examples.md.UIQU4FC2.js b/assets/examples.md.QyKLg778.js similarity index 96% rename from assets/examples.md.UIQU4FC2.js rename to assets/examples.md.QyKLg778.js index cd69064..8872684 100644 --- a/assets/examples.md.UIQU4FC2.js +++ b/assets/examples.md.QyKLg778.js @@ -1,4 +1,4 @@ -import{_ as s,o as i,c as a,R as n}from"./chunks/framework.FghLVCew.js";const o=JSON.parse('{"title":"Demo","description":"","frontmatter":{},"headers":[],"relativePath":"examples.md","filePath":"examples.md"}'),l={name:"examples.md"},h=n(`

Demo

In this page, you can find many example codes.

Vue.js

You can find a Vue.js example here.

vue
<script setup>
+import{_ as s,o as i,c as a,R as n}from"./chunks/framework.FghLVCew.js";const o=JSON.parse('{"title":"Demo","description":"","frontmatter":{},"headers":[],"relativePath":"examples.md","filePath":"examples.md"}'),l={name:"examples.md"},t=n(`

Demo

In this page, you can find many example codes.

Vue.js

You can find a Vue.js example here.

vue
<script setup>
 import { ref, computed } from "vue";
 import { validate, setLocales } from "robust-validator";
 import en from "robust-validator/dist/i18n/en.json";
@@ -22,7 +22,7 @@ import{_ as s,o as i,c as a,R as n}from"./chunks/framework.FghLVCew.js";const o=
     v-model="data.email"
     @input="validateData"
   />
-</template>

Node.js (CJS)

You can find a Node.js example here.

js
const { validate, setLocales } = require("robust-validator");
+</template>

Node.js (CJS)

You can find a Node.js example here.

js
const { validate, setLocales } = require("robust-validator");
 const en = require("robust-validator/dist/i18n/en.json");
 
 setLocales(en);
@@ -37,7 +37,7 @@ import{_ as s,o as i,c as a,R as n}from"./chunks/framework.FghLVCew.js";const o=
 
 validate({
   email: null,
-});

Node.js (ESM)

You can find a Node.js (ESM) example here.

js
import pkg from "robust-validator";
+});

Node.js (ESM)

You can find a Node.js (ESM) example here.

js
import pkg from "robust-validator";
 import en from "robust-validator/dist/i18n/en.json" assert { type: "json" };
 
 const { validate, setLocales } = pkg;
@@ -54,7 +54,7 @@ import{_ as s,o as i,c as a,R as n}from"./chunks/framework.FghLVCew.js";const o=
 
 validate({
   email: null,
-});

TypeScript

You can find a TypeScript example here.

js
import { validate, setLocales, setOptions } from "robust-validator";
+});

TypeScript

You can find a TypeScript example here.

js
import { validate, setLocales, setOptions } from "robust-validator";
 import en from "robust-validator/dist/i18n/en.json";
 
 setLocales(en);
@@ -69,4 +69,4 @@ import{_ as s,o as i,c as a,R as n}from"./chunks/framework.FghLVCew.js";const o=
 
 validate({
   email: null,
-});
`,14),t=[h];function p(k,e,E,d,r,g){return i(),a("div",null,t)}const c=s(l,[["render",p]]);export{o as __pageData,c as default}; +});
`,14),h=[t];function p(k,e,E,d,r,g){return i(),a("div",null,h)}const c=s(l,[["render",p]]);export{o as __pageData,c as default}; diff --git a/assets/examples.md.UIQU4FC2.lean.js b/assets/examples.md.QyKLg778.lean.js similarity index 65% rename from assets/examples.md.UIQU4FC2.lean.js rename to assets/examples.md.QyKLg778.lean.js index e9388ab..5cf9d14 100644 --- a/assets/examples.md.UIQU4FC2.lean.js +++ b/assets/examples.md.QyKLg778.lean.js @@ -1 +1 @@ -import{_ as s,o as i,c as a,R as n}from"./chunks/framework.FghLVCew.js";const o=JSON.parse('{"title":"Demo","description":"","frontmatter":{},"headers":[],"relativePath":"examples.md","filePath":"examples.md"}'),l={name:"examples.md"},h=n("",14),t=[h];function p(k,e,E,d,r,g){return i(),a("div",null,t)}const c=s(l,[["render",p]]);export{o as __pageData,c as default}; +import{_ as s,o as i,c as a,R as n}from"./chunks/framework.FghLVCew.js";const o=JSON.parse('{"title":"Demo","description":"","frontmatter":{},"headers":[],"relativePath":"examples.md","filePath":"examples.md"}'),l={name:"examples.md"},t=n("",14),h=[t];function p(k,e,E,d,r,g){return i(),a("div",null,h)}const c=s(l,[["render",p]]);export{o as __pageData,c as default}; diff --git a/assets/getting-started.md.Brfkmxof.js b/assets/getting-started.md.wh5gjnsX.js similarity index 98% rename from assets/getting-started.md.Brfkmxof.js rename to assets/getting-started.md.wh5gjnsX.js index 39c4776..0d27f64 100644 --- a/assets/getting-started.md.Brfkmxof.js +++ b/assets/getting-started.md.wh5gjnsX.js @@ -1,4 +1,4 @@ -import{_ as s,o as i,c as a,R as n}from"./chunks/framework.FghLVCew.js";const y=JSON.parse('{"title":"Getting started","description":"","frontmatter":{},"headers":[],"relativePath":"getting-started.md","filePath":"getting-started.md"}'),t={name:"getting-started.md"},l=n(`

Getting started

Installation

The library can be installed into an existing project:

bash
$ npm install --save robust-validator

Usage

Using robust-validator is very simple.

You should just call the validate() function with data and the definition.

js
import { validate, setLocales } from "robust-validator";
+import{_ as s,o as i,c as a,R as n}from"./chunks/framework.FghLVCew.js";const y=JSON.parse('{"title":"Getting started","description":"","frontmatter":{},"headers":[],"relativePath":"getting-started.md","filePath":"getting-started.md"}'),t={name:"getting-started.md"},l=n(`

Getting started

Installation

The library can be installed into an existing project:

bash
$ npm install --save robust-validator

Usage

Using robust-validator is very simple.

You should just call the validate() function with data and the definition.

js
import { validate, setLocales } from "robust-validator";
 import en from "robust-validator/dist/i18n/en.json";
 
 setLocales(en);
diff --git a/assets/getting-started.md.Brfkmxof.lean.js b/assets/getting-started.md.wh5gjnsX.lean.js
similarity index 100%
rename from assets/getting-started.md.Brfkmxof.lean.js
rename to assets/getting-started.md.wh5gjnsX.lean.js
diff --git a/assets/rules.md.MQiJJtnF.js b/assets/rules.md.RT1kuBUX.js
similarity index 93%
rename from assets/rules.md.MQiJJtnF.js
rename to assets/rules.md.RT1kuBUX.js
index 05541be..05596ff 100644
--- a/assets/rules.md.MQiJJtnF.js
+++ b/assets/rules.md.RT1kuBUX.js
@@ -1,160 +1,160 @@
-import{_ as s,o as i,c as a,R as t}from"./chunks/framework.FghLVCew.js";const E=JSON.parse('{"title":"Rules","description":"","frontmatter":{},"headers":[],"relativePath":"rules.md","filePath":"rules.md"}'),e={name:"rules.md"},d=t(`

Rules

In this section, you can find the truth tables for all validation rules.

TIP

You can learn more about the Rule Terminology.

WARNING

Each rule function should validate only one thing. For example, the email validation should NOT check if the data is provided. Otherwise, a rule function can not check the optional data.

That's why null and undefined values are acceptable for all rules except the required.

If you want to check if the data is provided and is a valid email, you should use two rules (required, email) at the same time.

accepted

The field under validation must be yes, on, 1 or true. This is useful for validating "Terms of Service" acceptance.

ts
import { validate } from "robust-validator";
+import{_ as s,o as i,c as a,R as t}from"./chunks/framework.FghLVCew.js";const E=JSON.parse('{"title":"Rules","description":"","frontmatter":{},"headers":[],"relativePath":"rules.md","filePath":"rules.md"}'),e={name:"rules.md"},d=t(`

Rules

In this section, you can find the truth tables for all validation rules.

TIP

You can learn more about the Rule Terminology.

WARNING

Each rule function should validate only one thing. For example, the email validation should NOT check if the data is provided. Otherwise, a rule function can not check the optional data.

That's why null and undefined values are acceptable for all rules except the required.

If you want to check if the data is provided and is a valid email, you should use two rules (required, email) at the same time.

accepted

The field under validation must be yes, on, 1 or true. This is useful for validating "Terms of Service" acceptance.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { terms: "accepted" });
ts
import { validate, accepted } from "robust-validator";
 // ...
 await validate(data, { terms: [accepted()] });
ts
import { isAccepted } from "robust-validator";
 // ...
-isAccepted("your-value");
RuleValueIs valid?
acceptednull🔴
acceptedundefined🔴
accepted'yes'🟢
accepted'on'🟢
accepted1🟢
acceptedtrue🟢
acceptedjohn🔴
accepted3.14🔴

after:date

The field under validation must be after the given date.

ts
import { validate } from "robust-validator";
+isAccepted("your-value");
RuleValueIs valid?
acceptednull🔴
acceptedundefined🔴
accepted'yes'🟢
accepted'on'🟢
accepted1🟢
acceptedtrue🟢
acceptedjohn🔴
accepted3.14🔴

after:date

The field under validation must be after the given date.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { startAt: "after:2023-01-01" });
ts
import { validate, after } from "robust-validator";
 // ...
 await validate(data, { startAt: [after("2023-01-01")] });
ts
import { isAfter } from "robust-validator";
 // ...
-isAfter("your-value", "2023-01-01");

TIP

robust-validator library uses the dayjs for the date validations.

You can check the possible date formats here.

WARNING

You MUST install the dayjs is to your project.

npm install dayjs or yarn add dayjs

RuleValuestartAtIs valid?
after:2024-01-01null🔴
after:2024-01-01undefined🔴
after:2024-01-012025-01-01🟢
after:startAt2025-01-012024-01-01🟢
after:startAt2024-01-012024-01-01🔴
after:startAt2024-01-012025-01-01🔴
after:2024-01-012024-01-01🔴
after:2024-01-012020-01-01🔴

after_or_equal:date

The field unter validation must be after or equal to the given field

ts
import { validate } from "robust-validator";
+isAfter("your-value", "2023-01-01");

TIP

robust-validator library uses the dayjs for the date validations.

You can check the possible date formats here.

WARNING

You MUST install the dayjs is to your project.

npm install dayjs or yarn add dayjs

RuleValuestartAtIs valid?
after:2024-01-01null🔴
after:2024-01-01undefined🔴
after:2024-01-012025-01-01🟢
after:startAt2025-01-012024-01-01🟢
after:startAt2024-01-012024-01-01🔴
after:startAt2024-01-012025-01-01🔴
after:2024-01-012024-01-01🔴
after:2024-01-012020-01-01🔴

after_or_equal:date

The field unter validation must be after or equal to the given field

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { startAt: "after_or_equal:2023-01-01" });
ts
import { validate, afterOrEqual } from "robust-validator";
 // ...
 await validate(data, { startAt: [afterOrEqual("2023-01-01")] });
ts
import { isAfterOrEqual } from "robust-validator";
 // ...
-isAfterOrEqual("your-value", "2023-01-01");

TIP

robust-validator library uses the dayjs for the date validations.

You can check the possible date formats here.

WARNING

You MUST install the dayjs is to your project.

npm install dayjs or yarn add dayjs

RuleValuestartAtIs valid?
after_or_equal:2024-01-01null🔴
after_or_equal:2024-01-01undefined🔴
after_or_equal:2024-01-012025-01-01🟢
after_or_equal:2024-01-012024-01-01🟢
after_or_equal:startAt2025-01-012024-01-01🟢
after_or_equal:startAt2024-01-012024-01-01🟢
after_or_equal:startAt2024-01-012025-01-01🔴
after_or_equal:2024-01-012020-01-01🔴

alpha

The field under validation must be entirely alphabetic characters.

ts
import { validate } from "robust-validator";
+isAfterOrEqual("your-value", "2023-01-01");

TIP

robust-validator library uses the dayjs for the date validations.

You can check the possible date formats here.

WARNING

You MUST install the dayjs is to your project.

npm install dayjs or yarn add dayjs

RuleValuestartAtIs valid?
after_or_equal:2024-01-01null🔴
after_or_equal:2024-01-01undefined🔴
after_or_equal:2024-01-012025-01-01🟢
after_or_equal:2024-01-012024-01-01🟢
after_or_equal:startAt2025-01-012024-01-01🟢
after_or_equal:startAt2024-01-012024-01-01🟢
after_or_equal:startAt2024-01-012025-01-01🔴
after_or_equal:2024-01-012020-01-01🔴

alpha

The field under validation must be entirely alphabetic characters.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { username: "alpha" });
ts
import { validate, alpha } from "robust-validator";
 // ...
 await validate(data, { username: [alpha()] });
ts
import { isAlpha } from "robust-validator";
 // ...
-isAlpha("your-value");
RuleValueIs valid?
alphanull🔴
alphaundefined🔴
alphajohn🟢
alphajohn123🔴
alphajohn-doe🔴
alpha123🔴
alpha3.14🔴
alphatrue🔴

alpha_dash

The field under validation may have alpha-numeric characters, as well as dashes and underscores.

ts
import { validate } from "robust-validator";
+isAlpha("your-value");
RuleValueIs valid?
alphanull🔴
alphaundefined🔴
alphajohn🟢
alphajohn123🔴
alphajohn-doe🔴
alpha123🔴
alpha3.14🔴
alphatrue🔴

alpha_dash

The field under validation may have alpha-numeric characters, as well as dashes and underscores.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { username: "alpha_dash" });
ts
import { validate, alphaDash } from "robust-validator";
 // ...
 await validate(data, { username: [alphaDash()] });
ts
import { isAlphaDash } from "robust-validator";
 // ...
-isAlphaDash("your-value");
RuleValueIs valid?
alpha_dashnull🔴
alpha_dashundefined🔴
alpha_dashjohn🟢
alpha_dashjohn-doe🟢
alpha_dashjohn_doe🟢
alpha_dashjohn123🔴
alpha_dash123🔴
alpha_dash3.14🔴
alpha_dashtrue🔴

alpha_num

The field under validation must be entirely alpha-numeric characters.

ts
import { validate } from "robust-validator";
+isAlphaDash("your-value");
RuleValueIs valid?
alpha_dashnull🔴
alpha_dashundefined🔴
alpha_dashjohn🟢
alpha_dashjohn-doe🟢
alpha_dashjohn_doe🟢
alpha_dashjohn123🔴
alpha_dash123🔴
alpha_dash3.14🔴
alpha_dashtrue🔴

alpha_num

The field under validation must be entirely alpha-numeric characters.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { username: "alpha_num" });
ts
import { validate, alphaNum } from "robust-validator";
 // ...
 await validate(data, { username: [alphaNum()] });
ts
import { isAlphaNum } from "robust-validator";
 // ...
-isAlphaNum("your-value");
RuleValueIs valid?
alpha_numnull🔴
alpha_numundefined🔴
alpha_numjohn🟢
alpha_numjohn123🟢
alpha_numjohn-doe🔴
alpha_numjohn_doe🔴
alpha_num123🔴
alpha_num3.14🔴
alpha_numtrue🔴

array

The field under validation must be an array.

ts
import { validate } from "robust-validator";
+isAlphaNum("your-value");
RuleValueIs valid?
alpha_numnull🔴
alpha_numundefined🔴
alpha_numjohn🟢
alpha_numjohn123🟢
alpha_numjohn-doe🔴
alpha_numjohn_doe🔴
alpha_num123🔴
alpha_num3.14🔴
alpha_numtrue🔴

array

The field under validation must be an array.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { selectedIds: "array" });
ts
import { validate, array } from "robust-validator";
 // ...
 await validate(data, { selectedIds: [array()] });
ts
import { isArray } from "robust-validator";
 // ...
-isArray([1, 2, 3]);
RuleValueIs valid?
arraynull🔴
arrayundefined🔴
array[]🟢
array[1, 2, 3]🟢
array[{"id": 1}]🟢
arrayjohn🔴
arrayjohn🔴
array123🔴
array3.14🔴
arraytrue🔴

before:date

The field under validation must be before the given date.

ts
import { validate } from "robust-validator";
+isArray([1, 2, 3]);
RuleValueIs valid?
arraynull🔴
arrayundefined🔴
array[]🟢
array[1, 2, 3]🟢
array[{"id": 1}]🟢
arrayjohn🔴
arrayjohn🔴
array123🔴
array3.14🔴
arraytrue🔴

before:date

The field under validation must be before the given date.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { startAt: "before:2023-01-01" });
ts
import { validate, before } from "robust-validator";
 // ...
 await validate(data, { startAt: [before("2023-01-01")] });
ts
import { isBefore } from "robust-validator";
 // ...
-isBefore("your-value", "2023-01-01");

TIP

robust-validator library uses the dayjs for the date validations.

You can check the possible date formats here.

WARNING

You MUST install the dayjs is to your project.

npm install dayjs or yarn add dayjs

RuleValuefinishAtIs valid?
before:2024-01-01null🔴
before:2024-01-01undefined🔴
before:2024-01-012023-01-01🟢
before:finishAt2023-01-012024-01-01🟢
before:finishAt2023-01-012023-01-01🔴
before:finishAt2023-01-012022-01-01🔴
before:2024-01-012024-01-01🔴
before:2024-01-012025-01-01🔴

before_or_equal:date

ts
import { validate } from "robust-validator";
+isBefore("your-value", "2023-01-01");

TIP

robust-validator library uses the dayjs for the date validations.

You can check the possible date formats here.

WARNING

You MUST install the dayjs is to your project.

npm install dayjs or yarn add dayjs

RuleValuefinishAtIs valid?
before:2024-01-01null🔴
before:2024-01-01undefined🔴
before:2024-01-012023-01-01🟢
before:finishAt2023-01-012024-01-01🟢
before:finishAt2023-01-012023-01-01🔴
before:finishAt2023-01-012022-01-01🔴
before:2024-01-012024-01-01🔴
before:2024-01-012025-01-01🔴

before_or_equal:date

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { startAt: "before_or_equal:2023-01-01" });
ts
import { validate, beforeOrEqual } from "robust-validator";
 // ...
 await validate(data, { startAt: [beforeOrEqual("2023-01-01")] });
ts
import { isBeforeOrEqual } from "robust-validator";
 // ...
-isBeforeOrEqual("your-value", "2023-01-01");

The field under validation must be before or equal to the given date.

TIP

robust-validator library uses the dayjs for the date validations.

You can check the possible date formats here.

WARNING

You MUST install the dayjs is to your project.

npm install dayjs or yarn add dayjs

RuleValuefinishAtIs valid?
before_or_equal:2024-01-01null🔴
before_or_equal:2024-01-01undefined🔴
before_or_equal:2024-01-012023-01-01🟢
before_or_equal:2024-01-012024-01-01🟢
before_or_equal:finishAt2023-01-012024-01-01🟢
before_or_equal:finishAt2023-01-012023-01-01🟢
before_or_equal:finishAt2023-01-012022-01-01🔴
before_or_equal:2024-01-012025-01-01🔴

between:min,max

The field under validation must have a size between the given min and max. Strings, and numerics are evaluated in the same fashion as the size rule.

ts
import { validate } from "robust-validator";
+isBeforeOrEqual("your-value", "2023-01-01");

The field under validation must be before or equal to the given date.

TIP

robust-validator library uses the dayjs for the date validations.

You can check the possible date formats here.

WARNING

You MUST install the dayjs is to your project.

npm install dayjs or yarn add dayjs

RuleValuefinishAtIs valid?
before_or_equal:2024-01-01null🔴
before_or_equal:2024-01-01undefined🔴
before_or_equal:2024-01-012023-01-01🟢
before_or_equal:2024-01-012024-01-01🟢
before_or_equal:finishAt2023-01-012024-01-01🟢
before_or_equal:finishAt2023-01-012023-01-01🟢
before_or_equal:finishAt2023-01-012022-01-01🔴
before_or_equal:2024-01-012025-01-01🔴

between:min,max

The field under validation must have a size between the given min and max. Strings, and numerics are evaluated in the same fashion as the size rule.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { score: "between:1,10" });
ts
import { validate, score } from "robust-validator";
 // ...
 await validate(data, { score: [score(1, 10)] });
ts
import { isBetween } from "robust-validator";
 // ...
-isBetween(3, 1, 10);
RuleValueIs valid?
between:1,5null🔴
between:1,5undefined🔴
between:1,5'john'🟢
between:1,5'12345'🟢
between:1,5long-text🔴
between:1,512345🔴

boolean

The field under validation must be a boolean value of the form true, false, 0, 1, 'true', 'false', '0', '1',

ts
import { validate } from "robust-validator";
+isBetween(3, 1, 10);
RuleValueIs valid?
between:1,5null🔴
between:1,5undefined🔴
between:1,5'john'🟢
between:1,5'12345'🟢
between:1,5long-text🔴
between:1,512345🔴

boolean

The field under validation must be a boolean value of the form true, false, 0, 1, 'true', 'false', '0', '1',

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { isOpen: "boolean" });
ts
import { validate, boolean } from "robust-validator";
 // ...
 await validate(data, { isOpen: [boolean()] });
ts
import { isBoolean } from "robust-validator";
 // ...
-isBoolean(true);
RuleValueIs valid?
booleannull🔴
booleanundefined🔴
booleantrue🟢
boolean'true'🟢
boolean1🟢
boolean'1'🟢
booleanfalse🔴
boolean'false'🔴
boolean0🔴
boolean'0'🔴

confirmed

The field under validation must have a matching field of foo_confirmation. For example, if the field under validation is password, a matching password_confirmation field must be present in the input.

Let's assume that the value of the password field is 123456. If you use the confirmed definition on the password field's rules, the truth table would look like the following example:

ts
import { validate } from "robust-validator";
+isBoolean(true);
RuleValueIs valid?
booleannull🔴
booleanundefined🔴
booleantrue🟢
boolean'true'🟢
boolean1🟢
boolean'1'🟢
booleanfalse🔴
boolean'false'🔴
boolean0🔴
boolean'0'🔴

confirmed

The field under validation must have a matching field of foo_confirmation. For example, if the field under validation is password, a matching password_confirmation field must be present in the input.

Let's assume that the value of the password field is 123456. If you use the confirmed definition on the password field's rules, the truth table would look like the following example:

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { password: "confirmed" });
ts
import { validate, confirmed } from "robust-validator";
 // ...
 await validate(data, { password: [confirmed()] });
ts
import { isConfirmed } from "robust-validator";
 // ...
-isConfirmed("your-data");
FieldValueIs valid?
password_confirmation123456🟢
password_confirmation654321🔴
password_confirmationnull🔴
password_confirmationundefined🔴
password_confirmationtrue🔴
password_confirmationfalse🔴
password_confirmation{}🔴

date:format

The field under validation must be a valid date format which is acceptable by Javascript's Date object.

ts
import { validate } from "robust-validator";
+isConfirmed("your-data");
FieldValueIs valid?
password_confirmation123456🟢
password_confirmation654321🔴
password_confirmationnull🔴
password_confirmationundefined🔴
password_confirmationtrue🔴
password_confirmationfalse🔴
password_confirmation{}🔴

date:format

The field under validation must be a valid date format which is acceptable by Javascript's Date object.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { startAt: "date:YYYY-MM-DD" });
ts
import { validate, date } from "robust-validator";
 // ...
 await validate(data, { startAt: [date("YYYY-MM-DD")] });
ts
import { isDate } from "robust-validator";
 // ...
-isDate("your-data", "YYYY-MM-DD");
RuleValueIs valid?
date:YYYY-MM-DDnull🔴
date:YYYY-MM-DDundefined🔴
date:YYYY-MM-DD2023-12-16🟢
date:YYYY-MM-DD2023-01-01🟢
date:YYYY-MM-DDDecember 16, 2023 12:00:00🔴
date:YYYY-MM-DD2022-13-01🔴
date:YYYY-MM-DD2022-12-32🔴
date:YYYY-MM-DD2022-02-29🔴
date:YYYY-MM-DDfalse🔴

digits:value

The field under validation must be numeric and must have an exact length of value.

ts
import { validate } from "robust-validator";
+isDate("your-data", "YYYY-MM-DD");
RuleValueIs valid?
date:YYYY-MM-DDnull🔴
date:YYYY-MM-DDundefined🔴
date:YYYY-MM-DD2023-12-16🟢
date:YYYY-MM-DD2023-01-01🟢
date:YYYY-MM-DDDecember 16, 2023 12:00:00🔴
date:YYYY-MM-DD2022-13-01🔴
date:YYYY-MM-DD2022-12-32🔴
date:YYYY-MM-DD2022-02-29🔴
date:YYYY-MM-DDfalse🔴

digits:value

The field under validation must be numeric and must have an exact length of value.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { pin: "digits:4" });
ts
import { validate, digits } from "robust-validator";
 // ...
 await validate(data, { pin: [digits(4)] });
ts
import { isDigits } from "robust-validator";
 // ...
-isDigits("1234", 4);
RuleValueIs valid?
digits:4null🔴
digits:4undefined🔴
digits:41234🟢
digits:4123🔴
digits:4true🔴
digits:4'1234'🔴
digits:4123456🔴

digits_between:min,max

The field under validation must be numeric and must have length between given min and max.

ts
import { validate } from "robust-validator";
+isDigits("1234", 4);
RuleValueIs valid?
digits:4null🔴
digits:4undefined🔴
digits:41234🟢
digits:4123🔴
digits:4true🔴
digits:4'1234'🔴
digits:4123456🔴

digits_between:min,max

The field under validation must be numeric and must have length between given min and max.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { pin: "digits_between:4,6" });
ts
import { validate, digitsBetween } from "robust-validator";
 // ...
 await validate(data, { pin: [digitsBetween(4, 6)] });
ts
import { isdigitsBetween } from "robust-validator";
 // ...
-isdigitsBetween("1234", 4, 6);
RuleValueIs valid?
digits_between:4,6null🔴
digits_between:4,6undefined🔴
digits_between:4,61234🟢
digits_between:4,6123456🟢
digits_between:4,6123🔴
digits_between:4,6true🔴
digits_between:4,6'1234'🔴

email

The field under validation must be formatted as an e-mail address.

ts
import { validate } from "robust-validator";
+isdigitsBetween("1234", 4, 6);
RuleValueIs valid?
digits_between:4,6null🔴
digits_between:4,6undefined🔴
digits_between:4,61234🟢
digits_between:4,6123456🟢
digits_between:4,6123🔴
digits_between:4,6true🔴
digits_between:4,6'1234'🔴

email

The field under validation must be formatted as an e-mail address.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { contact_email: "email" });
ts
import { validate, email } from "robust-validator";
 // ...
 await validate(data, { contact_email: [email()] });
ts
import { isEmail } from "robust-validator";
 // ...
-isEmail("your-date");
RuleValueIs valid?
emailnull🔴
emailundefined🔴
emailfoo@bar.com🟢
emailjust a text🔴
emailtrue🔴
email'1234'🔴

hex

The field under validation should be a hexadecimal format.

ts
import { validate } from "robust-validator";
+isEmail("your-date");
RuleValueIs valid?
emailnull🔴
emailundefined🔴
emailfoo@bar.com🟢
emailjust a text🔴
emailtrue🔴
email'1234'🔴

hex

The field under validation should be a hexadecimal format.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { colorCode: "hex" });
ts
import { validate, hex } from "robust-validator";
 // ...
 await validate(data, { colorCode: [hex()] });
ts
import { isHex } from "robust-validator";
 // ...
-isHex("f1f1f1");
RuleValueIs valid?
hexnull🔴
hexundefined🔴
hex1aF🟢
hex1234567890ABCDEF🟢
hex123xyz🔴
hex0xg🔴
hexinvalid string🔴

in:foo,bar,...

The field under validation must be included in the given list of values.

ts
import { validate } from "robust-validator";
+isHex("f1f1f1");
RuleValueIs valid?
hexnull🔴
hexundefined🔴
hex1aF🟢
hex1234567890ABCDEF🟢
hex123xyz🔴
hex0xg🔴
hexinvalid string🔴

in:foo,bar,...

The field under validation must be included in the given list of values.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { userChoice: "in:news,marketing" });
ts
import { validate, in } from "robust-validator";
 // ...
 await validate(data, { userChoice: [in(["news", "marketing"])] });
ts
import { isIn } from "robust-validator";
 // ...
-isIn("your-data", ["news", "marketing"]);
RuleValueIs valid?
in:A,Bnull🔴
in:A,Bundefined🔴
in:A,BA🟢
in:A,BB🟢
in:A,BC🔴
in:A,Btrue🔴
in:A,B{}🔴

integer

The field under validation must have an integer value.

ts
import { validate } from "robust-validator";
+isIn("your-data", ["news", "marketing"]);
RuleValueIs valid?
in:A,Bnull🔴
in:A,Bundefined🔴
in:A,BA🟢
in:A,BB🟢
in:A,BC🔴
in:A,Btrue🔴
in:A,B{}🔴

integer

The field under validation must have an integer value.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { age: "integer" });
ts
import { validate, integer } from "robust-validator";
 // ...
 await validate(data, { age: [integer()] });
ts
import { isInteger } from "robust-validator";
 // ...
-isInteger(134);
RuleValueIs valid?
integernull🔴
integerundefined🔴
integer123🟢
integer3.14🔴
integerabc🔴

max:value

Validate that an attribute is no greater than a given size

ts
import { validate } from "robust-validator";
+isInteger(134);
RuleValueIs valid?
integernull🔴
integerundefined🔴
integer123🟢
integer3.14🔴
integerabc🔴

max:value

Validate that an attribute is no greater than a given size

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { age: "max:99" });
ts
import { validate, max } from "robust-validator";
 // ...
 await validate(data, { age: [max(99)] });
ts
import { isMax } from "robust-validator";
 // ...
-isMax(10, 99);
RuleValueIs valid?
max:5null🔴
max:5undefined🔴
max:5'123'🟢
max:53🟢
max:5'abcdef'🔴
max:510🔴

min:value

Validate that an attribute is at least a given size.

ts
import { validate } from "robust-validator";
+isMax(10, 99);
RuleValueIs valid?
max:5null🔴
max:5undefined🔴
max:5'123'🟢
max:53🟢
max:5'abcdef'🔴
max:510🔴

min:value

Validate that an attribute is at least a given size.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { age: "min:22" });
ts
import { validate, min } from "robust-validator";
 // ...
 await validate(data, { age: [min(22)] });
ts
import { isMin } from "robust-validator";
 // ...
-isMin(10, 22);
RuleValueIs valid?
min:5null🔴
min:5undefined🔴
min:5'abcdef'🟢
min:5'123456'🟢
min:510🟢
min:5'abcdef'🔴
min:52🔴

not_in:foo,bar,...

The field under validation must not be included in the given list of values.

ts
import { validate } from "robust-validator";
+isMin(10, 22);
RuleValueIs valid?
min:5null🔴
min:5undefined🔴
min:5'abcdef'🟢
min:5'123456'🟢
min:510🟢
min:5'abcdef'🔴
min:52🔴

not_in:foo,bar,...

The field under validation must not be included in the given list of values.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { userChoice: "not_in:news,marketing" });
ts
import { validate, notIn } from "robust-validator";
 // ...
 await validate(data, { userChoice: [notIn(["news", "marketing"])] });
ts
import { isNotIn } from "robust-validator";
 // ...
-isNotIn("your-data", ["news", "marketing"]);
RuleValueIs valid?
not_in:A,Bnull🔴
not_in:A,Bundefined🔴
not_in:A,BC🟢
not_in:A,BA🔴
not_in:A,BB🔴
not_in:A,Btrue🔴

numeric

Validate that an attribute is numeric.

ts
import { validate } from "robust-validator";
+isNotIn("your-data", ["news", "marketing"]);
RuleValueIs valid?
not_in:A,Bnull🔴
not_in:A,Bundefined🔴
not_in:A,BC🟢
not_in:A,BA🔴
not_in:A,BB🔴
not_in:A,Btrue🔴

numeric

Validate that an attribute is numeric.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { salary: "numeric" });
ts
import { validate, numeric } from "robust-validator";
 // ...
 await validate(data, { salary: [numeric()] });
ts
import { isNumeric } from "robust-validator";
 // ...
-isNumeric(3000);
RuleValueIs valid?
integernull🔴
integerundefined🔴
integer123🟢
integer3.14🟢
integerabc🔴

required

Checks if the value is provided.

ts
import { validate } from "robust-validator";
+isNumeric(3000);
RuleValueIs valid?
integernull🔴
integerundefined🔴
integer123🟢
integer3.14🟢
integerabc🔴

required

Checks if the value is provided.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { salary: "required" });
ts
import { validate, required } from "robust-validator";
 // ...
 await validate(data, { salary: [required()] });
ts
import { isRequired } from "robust-validator";
 // ...
-isRequired("your-data");
RuleValueIs valid?
requiredjohn🟢
required123🟢
required1.23🟢
required{}🟢
requirednull🔴
requiredundefined🔴
required''🔴
required' '🔴

size:value

The field under validation must have a size matching the given value. For string data, value corresponds to the number of characters. For numeric data, value corresponds to a given integer value.

ts
import { validate } from "robust-validator";
+isRequired("your-data");
RuleValueIs valid?
requiredjohn🟢
required123🟢
required1.23🟢
required{}🟢
requirednull🔴
requiredundefined🔴
required''🔴
required' '🔴

size:value

The field under validation must have a size matching the given value. For string data, value corresponds to the number of characters. For numeric data, value corresponds to a given integer value.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { password: "size:12" });
ts
import { validate, size } from "robust-validator";
 // ...
 await validate(data, { password: [size(12)] });
ts
import { isSize } from "robust-validator";
 // ...
-isSize("your-data", 12);
RuleValueIs valid?
size:3null🔴
size:3undefined🔴
size:3abc🟢
size:31🟢
size:31.23🟢
size:3abcde🔴
size:310🔴

string

The field under validation must be a string.

ts
import { validate } from "robust-validator";
+isSize("your-data", 12);
RuleValueIs valid?
size:3null🔴
size:3undefined🔴
size:3abc🟢
size:31🟢
size:31.23🟢
size:3abcde🔴
size:310🔴

string

The field under validation must be a string.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { content: "string" });
ts
import { validate, string } from "robust-validator";
 // ...
 await validate(data, { content: [string()] });
ts
import { isString } from "robust-validator";
 // ...
-isString("your-data");
RuleValueIs valid?
stringabc🟢
string''🟢
string' '🟢
string1🔴
string1.23🔴
stringabcde🔴
string10🔴
stringnull🔴
stringundefined🔴

url

Validate that an attribute has a valid URL format

ts
import { validate } from "robust-validator";
+isString("your-data");
RuleValueIs valid?
stringabc🟢
string''🟢
string' '🟢
string1🔴
string1.23🔴
stringabcde🔴
string10🔴
stringnull🔴
stringundefined🔴

url

Validate that an attribute has a valid URL format

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { profile: "url" });
ts
import { validate, url } from "robust-validator";
 // ...
diff --git a/assets/rules.md.MQiJJtnF.lean.js b/assets/rules.md.RT1kuBUX.lean.js
similarity index 100%
rename from assets/rules.md.MQiJJtnF.lean.js
rename to assets/rules.md.RT1kuBUX.lean.js
diff --git a/customization.html b/customization.html
index 09ce073..eb9d059 100644
--- a/customization.html
+++ b/customization.html
@@ -45,7 +45,7 @@
     },
   );
 };

Released under the MIT License.

- + \ No newline at end of file diff --git a/examples.html b/examples.html index aae3f64..f44e4bc 100644 --- a/examples.html +++ b/examples.html @@ -12,12 +12,12 @@ - + -
Skip to content

Demo

In this page, you can find many example codes.

Vue.js

You can find a Vue.js example here.

vue
<script setup>
+    
Skip to content

Demo

In this page, you can find many example codes.

Vue.js

You can find a Vue.js example here.

vue
<script setup>
 import { ref, computed } from "vue";
 import { validate, setLocales } from "robust-validator";
 import en from "robust-validator/dist/i18n/en.json";
@@ -41,7 +41,7 @@
     v-model="data.email"
     @input="validateData"
   />
-</template>

Node.js (CJS)

You can find a Node.js example here.

js
const { validate, setLocales } = require("robust-validator");
+</template>

Node.js (CJS)

You can find a Node.js example here.

js
const { validate, setLocales } = require("robust-validator");
 const en = require("robust-validator/dist/i18n/en.json");
 
 setLocales(en);
@@ -56,7 +56,7 @@
 
 validate({
   email: null,
-});

Node.js (ESM)

You can find a Node.js (ESM) example here.

js
import pkg from "robust-validator";
+});

Node.js (ESM)

You can find a Node.js (ESM) example here.

js
import pkg from "robust-validator";
 import en from "robust-validator/dist/i18n/en.json" assert { type: "json" };
 
 const { validate, setLocales } = pkg;
@@ -73,7 +73,7 @@
 
 validate({
   email: null,
-});

TypeScript

You can find a TypeScript example here.

js
import { validate, setLocales, setOptions } from "robust-validator";
+});

TypeScript

You can find a TypeScript example here.

js
import { validate, setLocales, setOptions } from "robust-validator";
 import en from "robust-validator/dist/i18n/en.json";
 
 setLocales(en);
@@ -89,7 +89,7 @@
 validate({
   email: null,
 });

Released under the MIT License.

- + \ No newline at end of file diff --git a/getting-started.html b/getting-started.html index b571c95..56a750f 100644 --- a/getting-started.html +++ b/getting-started.html @@ -12,12 +12,12 @@ - + -
Skip to content

Getting started

Installation

The library can be installed into an existing project:

bash
$ npm install --save robust-validator

Usage

Using robust-validator is very simple.

You should just call the validate() function with data and the definition.

js
import { validate, setLocales } from "robust-validator";
+    
Skip to content

Getting started

Installation

The library can be installed into an existing project:

bash
$ npm install --save robust-validator

Usage

Using robust-validator is very simple.

You should just call the validate() function with data and the definition.

js
import { validate, setLocales } from "robust-validator";
 import en from "robust-validator/dist/i18n/en.json";
 
 setLocales(en);
@@ -77,7 +77,7 @@
     ]
   }
 }

Released under the MIT License.

- + \ No newline at end of file diff --git a/hashmap.json b/hashmap.json index dab0fb0..26e5104 100644 --- a/hashmap.json +++ b/hashmap.json @@ -1 +1 @@ -{"api-examples.md":"wOFSxzQq","i18n.md":"OMJQmP09","customization.md":"LLNYVo54","examples.md":"UIQU4FC2","index.md":"oGu1lJgi","options.md":"J8mPoffA","rules.md":"MQiJJtnF","why.md":"a8Yr0n_9","terminology.md":"MCStHf-x","getting-started.md":"Brfkmxof"} +{"examples.md":"QyKLg778","api-examples.md":"wOFSxzQq","i18n.md":"OMJQmP09","terminology.md":"MCStHf-x","options.md":"J8mPoffA","why.md":"a8Yr0n_9","customization.md":"LLNYVo54","index.md":"oGu1lJgi","getting-started.md":"wh5gjnsX","rules.md":"RT1kuBUX"} diff --git a/i18n.html b/i18n.html index 260dd09..333e7de 100644 --- a/i18n.html +++ b/i18n.html @@ -31,7 +31,7 @@ setOptions({ language: "en", });

Active language

You can override the active language by users' selection for every data validation.

ts
await validate(data, { email: "required" }, { language: "de" });

Supported Languages

Code (ISO 639-1)Language Name
arArabic
azAzerbaijani
beBelarusian
bgBulgarian
bsBosnian
caCatalan
csCzech
cyWelsh
daDanish
deGerman
elGreek
enEnglish
esSpanish
etEstonian
euBasque
faPersian
fiFinnish
frFrench
hrCroatian
huHungarian
idIndonesian
itItalian
jaJapanese
kaGeorgian
koKorean
liLimburgish
ltLithuanian
lvLatvian
mkMacedonian
mnMongolian
msMalay
noNorwegian
nlDutch
plPolish
ptPortuguese
roRomanian
ruRussian
seNorthern Sami
slSlovenian
sqAlbanian
srSerbian
svSwedish
trTurkish
ukUkrainian
viVietnamese
zhChinese

Released under the MIT License.

- + \ No newline at end of file diff --git a/index.html b/index.html index e52ffa2..8fa5826 100644 --- a/index.html +++ b/index.html @@ -18,7 +18,7 @@
Skip to content

Robust Validator

Rule-based data validation in JS

Extendable, function-oriented, i18n-supported

Released under the MIT License.

- + \ No newline at end of file diff --git a/options.html b/options.html index dc9fb1e..090a03e 100644 --- a/options.html +++ b/options.html @@ -49,7 +49,7 @@ dateFormat: "YYYY-MM-DD", }, );

Released under the MIT License.

- + \ No newline at end of file diff --git a/rules.html b/rules.html index 4990244..1571a84 100644 --- a/rules.html +++ b/rules.html @@ -12,175 +12,175 @@ - + -
Skip to content

Rules

In this section, you can find the truth tables for all validation rules.

TIP

You can learn more about the Rule Terminology.

WARNING

Each rule function should validate only one thing. For example, the email validation should NOT check if the data is provided. Otherwise, a rule function can not check the optional data.

That's why null and undefined values are acceptable for all rules except the required.

If you want to check if the data is provided and is a valid email, you should use two rules (required, email) at the same time.

accepted

The field under validation must be yes, on, 1 or true. This is useful for validating "Terms of Service" acceptance.

ts
import { validate } from "robust-validator";
+    
Skip to content

Rules

In this section, you can find the truth tables for all validation rules.

TIP

You can learn more about the Rule Terminology.

WARNING

Each rule function should validate only one thing. For example, the email validation should NOT check if the data is provided. Otherwise, a rule function can not check the optional data.

That's why null and undefined values are acceptable for all rules except the required.

If you want to check if the data is provided and is a valid email, you should use two rules (required, email) at the same time.

accepted

The field under validation must be yes, on, 1 or true. This is useful for validating "Terms of Service" acceptance.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { terms: "accepted" });
ts
import { validate, accepted } from "robust-validator";
 // ...
 await validate(data, { terms: [accepted()] });
ts
import { isAccepted } from "robust-validator";
 // ...
-isAccepted("your-value");
RuleValueIs valid?
acceptednull🔴
acceptedundefined🔴
accepted'yes'🟢
accepted'on'🟢
accepted1🟢
acceptedtrue🟢
acceptedjohn🔴
accepted3.14🔴

after:date

The field under validation must be after the given date.

ts
import { validate } from "robust-validator";
+isAccepted("your-value");
RuleValueIs valid?
acceptednull🔴
acceptedundefined🔴
accepted'yes'🟢
accepted'on'🟢
accepted1🟢
acceptedtrue🟢
acceptedjohn🔴
accepted3.14🔴

after:date

The field under validation must be after the given date.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { startAt: "after:2023-01-01" });
ts
import { validate, after } from "robust-validator";
 // ...
 await validate(data, { startAt: [after("2023-01-01")] });
ts
import { isAfter } from "robust-validator";
 // ...
-isAfter("your-value", "2023-01-01");

TIP

robust-validator library uses the dayjs for the date validations.

You can check the possible date formats here.

WARNING

You MUST install the dayjs is to your project.

npm install dayjs or yarn add dayjs

RuleValuestartAtIs valid?
after:2024-01-01null🔴
after:2024-01-01undefined🔴
after:2024-01-012025-01-01🟢
after:startAt2025-01-012024-01-01🟢
after:startAt2024-01-012024-01-01🔴
after:startAt2024-01-012025-01-01🔴
after:2024-01-012024-01-01🔴
after:2024-01-012020-01-01🔴

after_or_equal:date

The field unter validation must be after or equal to the given field

ts
import { validate } from "robust-validator";
+isAfter("your-value", "2023-01-01");

TIP

robust-validator library uses the dayjs for the date validations.

You can check the possible date formats here.

WARNING

You MUST install the dayjs is to your project.

npm install dayjs or yarn add dayjs

RuleValuestartAtIs valid?
after:2024-01-01null🔴
after:2024-01-01undefined🔴
after:2024-01-012025-01-01🟢
after:startAt2025-01-012024-01-01🟢
after:startAt2024-01-012024-01-01🔴
after:startAt2024-01-012025-01-01🔴
after:2024-01-012024-01-01🔴
after:2024-01-012020-01-01🔴

after_or_equal:date

The field unter validation must be after or equal to the given field

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { startAt: "after_or_equal:2023-01-01" });
ts
import { validate, afterOrEqual } from "robust-validator";
 // ...
 await validate(data, { startAt: [afterOrEqual("2023-01-01")] });
ts
import { isAfterOrEqual } from "robust-validator";
 // ...
-isAfterOrEqual("your-value", "2023-01-01");

TIP

robust-validator library uses the dayjs for the date validations.

You can check the possible date formats here.

WARNING

You MUST install the dayjs is to your project.

npm install dayjs or yarn add dayjs

RuleValuestartAtIs valid?
after_or_equal:2024-01-01null🔴
after_or_equal:2024-01-01undefined🔴
after_or_equal:2024-01-012025-01-01🟢
after_or_equal:2024-01-012024-01-01🟢
after_or_equal:startAt2025-01-012024-01-01🟢
after_or_equal:startAt2024-01-012024-01-01🟢
after_or_equal:startAt2024-01-012025-01-01🔴
after_or_equal:2024-01-012020-01-01🔴

alpha

The field under validation must be entirely alphabetic characters.

ts
import { validate } from "robust-validator";
+isAfterOrEqual("your-value", "2023-01-01");

TIP

robust-validator library uses the dayjs for the date validations.

You can check the possible date formats here.

WARNING

You MUST install the dayjs is to your project.

npm install dayjs or yarn add dayjs

RuleValuestartAtIs valid?
after_or_equal:2024-01-01null🔴
after_or_equal:2024-01-01undefined🔴
after_or_equal:2024-01-012025-01-01🟢
after_or_equal:2024-01-012024-01-01🟢
after_or_equal:startAt2025-01-012024-01-01🟢
after_or_equal:startAt2024-01-012024-01-01🟢
after_or_equal:startAt2024-01-012025-01-01🔴
after_or_equal:2024-01-012020-01-01🔴

alpha

The field under validation must be entirely alphabetic characters.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { username: "alpha" });
ts
import { validate, alpha } from "robust-validator";
 // ...
 await validate(data, { username: [alpha()] });
ts
import { isAlpha } from "robust-validator";
 // ...
-isAlpha("your-value");
RuleValueIs valid?
alphanull🔴
alphaundefined🔴
alphajohn🟢
alphajohn123🔴
alphajohn-doe🔴
alpha123🔴
alpha3.14🔴
alphatrue🔴

alpha_dash

The field under validation may have alpha-numeric characters, as well as dashes and underscores.

ts
import { validate } from "robust-validator";
+isAlpha("your-value");
RuleValueIs valid?
alphanull🔴
alphaundefined🔴
alphajohn🟢
alphajohn123🔴
alphajohn-doe🔴
alpha123🔴
alpha3.14🔴
alphatrue🔴

alpha_dash

The field under validation may have alpha-numeric characters, as well as dashes and underscores.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { username: "alpha_dash" });
ts
import { validate, alphaDash } from "robust-validator";
 // ...
 await validate(data, { username: [alphaDash()] });
ts
import { isAlphaDash } from "robust-validator";
 // ...
-isAlphaDash("your-value");
RuleValueIs valid?
alpha_dashnull🔴
alpha_dashundefined🔴
alpha_dashjohn🟢
alpha_dashjohn-doe🟢
alpha_dashjohn_doe🟢
alpha_dashjohn123🔴
alpha_dash123🔴
alpha_dash3.14🔴
alpha_dashtrue🔴

alpha_num

The field under validation must be entirely alpha-numeric characters.

ts
import { validate } from "robust-validator";
+isAlphaDash("your-value");
RuleValueIs valid?
alpha_dashnull🔴
alpha_dashundefined🔴
alpha_dashjohn🟢
alpha_dashjohn-doe🟢
alpha_dashjohn_doe🟢
alpha_dashjohn123🔴
alpha_dash123🔴
alpha_dash3.14🔴
alpha_dashtrue🔴

alpha_num

The field under validation must be entirely alpha-numeric characters.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { username: "alpha_num" });
ts
import { validate, alphaNum } from "robust-validator";
 // ...
 await validate(data, { username: [alphaNum()] });
ts
import { isAlphaNum } from "robust-validator";
 // ...
-isAlphaNum("your-value");
RuleValueIs valid?
alpha_numnull🔴
alpha_numundefined🔴
alpha_numjohn🟢
alpha_numjohn123🟢
alpha_numjohn-doe🔴
alpha_numjohn_doe🔴
alpha_num123🔴
alpha_num3.14🔴
alpha_numtrue🔴

array

The field under validation must be an array.

ts
import { validate } from "robust-validator";
+isAlphaNum("your-value");
RuleValueIs valid?
alpha_numnull🔴
alpha_numundefined🔴
alpha_numjohn🟢
alpha_numjohn123🟢
alpha_numjohn-doe🔴
alpha_numjohn_doe🔴
alpha_num123🔴
alpha_num3.14🔴
alpha_numtrue🔴

array

The field under validation must be an array.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { selectedIds: "array" });
ts
import { validate, array } from "robust-validator";
 // ...
 await validate(data, { selectedIds: [array()] });
ts
import { isArray } from "robust-validator";
 // ...
-isArray([1, 2, 3]);
RuleValueIs valid?
arraynull🔴
arrayundefined🔴
array[]🟢
array[1, 2, 3]🟢
array[{"id": 1}]🟢
arrayjohn🔴
arrayjohn🔴
array123🔴
array3.14🔴
arraytrue🔴

before:date

The field under validation must be before the given date.

ts
import { validate } from "robust-validator";
+isArray([1, 2, 3]);
RuleValueIs valid?
arraynull🔴
arrayundefined🔴
array[]🟢
array[1, 2, 3]🟢
array[{"id": 1}]🟢
arrayjohn🔴
arrayjohn🔴
array123🔴
array3.14🔴
arraytrue🔴

before:date

The field under validation must be before the given date.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { startAt: "before:2023-01-01" });
ts
import { validate, before } from "robust-validator";
 // ...
 await validate(data, { startAt: [before("2023-01-01")] });
ts
import { isBefore } from "robust-validator";
 // ...
-isBefore("your-value", "2023-01-01");

TIP

robust-validator library uses the dayjs for the date validations.

You can check the possible date formats here.

WARNING

You MUST install the dayjs is to your project.

npm install dayjs or yarn add dayjs

RuleValuefinishAtIs valid?
before:2024-01-01null🔴
before:2024-01-01undefined🔴
before:2024-01-012023-01-01🟢
before:finishAt2023-01-012024-01-01🟢
before:finishAt2023-01-012023-01-01🔴
before:finishAt2023-01-012022-01-01🔴
before:2024-01-012024-01-01🔴
before:2024-01-012025-01-01🔴

before_or_equal:date

ts
import { validate } from "robust-validator";
+isBefore("your-value", "2023-01-01");

TIP

robust-validator library uses the dayjs for the date validations.

You can check the possible date formats here.

WARNING

You MUST install the dayjs is to your project.

npm install dayjs or yarn add dayjs

RuleValuefinishAtIs valid?
before:2024-01-01null🔴
before:2024-01-01undefined🔴
before:2024-01-012023-01-01🟢
before:finishAt2023-01-012024-01-01🟢
before:finishAt2023-01-012023-01-01🔴
before:finishAt2023-01-012022-01-01🔴
before:2024-01-012024-01-01🔴
before:2024-01-012025-01-01🔴

before_or_equal:date

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { startAt: "before_or_equal:2023-01-01" });
ts
import { validate, beforeOrEqual } from "robust-validator";
 // ...
 await validate(data, { startAt: [beforeOrEqual("2023-01-01")] });
ts
import { isBeforeOrEqual } from "robust-validator";
 // ...
-isBeforeOrEqual("your-value", "2023-01-01");

The field under validation must be before or equal to the given date.

TIP

robust-validator library uses the dayjs for the date validations.

You can check the possible date formats here.

WARNING

You MUST install the dayjs is to your project.

npm install dayjs or yarn add dayjs

RuleValuefinishAtIs valid?
before_or_equal:2024-01-01null🔴
before_or_equal:2024-01-01undefined🔴
before_or_equal:2024-01-012023-01-01🟢
before_or_equal:2024-01-012024-01-01🟢
before_or_equal:finishAt2023-01-012024-01-01🟢
before_or_equal:finishAt2023-01-012023-01-01🟢
before_or_equal:finishAt2023-01-012022-01-01🔴
before_or_equal:2024-01-012025-01-01🔴

between:min,max

The field under validation must have a size between the given min and max. Strings, and numerics are evaluated in the same fashion as the size rule.

ts
import { validate } from "robust-validator";
+isBeforeOrEqual("your-value", "2023-01-01");

The field under validation must be before or equal to the given date.

TIP

robust-validator library uses the dayjs for the date validations.

You can check the possible date formats here.

WARNING

You MUST install the dayjs is to your project.

npm install dayjs or yarn add dayjs

RuleValuefinishAtIs valid?
before_or_equal:2024-01-01null🔴
before_or_equal:2024-01-01undefined🔴
before_or_equal:2024-01-012023-01-01🟢
before_or_equal:2024-01-012024-01-01🟢
before_or_equal:finishAt2023-01-012024-01-01🟢
before_or_equal:finishAt2023-01-012023-01-01🟢
before_or_equal:finishAt2023-01-012022-01-01🔴
before_or_equal:2024-01-012025-01-01🔴

between:min,max

The field under validation must have a size between the given min and max. Strings, and numerics are evaluated in the same fashion as the size rule.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { score: "between:1,10" });
ts
import { validate, score } from "robust-validator";
 // ...
 await validate(data, { score: [score(1, 10)] });
ts
import { isBetween } from "robust-validator";
 // ...
-isBetween(3, 1, 10);
RuleValueIs valid?
between:1,5null🔴
between:1,5undefined🔴
between:1,5'john'🟢
between:1,5'12345'🟢
between:1,5long-text🔴
between:1,512345🔴

boolean

The field under validation must be a boolean value of the form true, false, 0, 1, 'true', 'false', '0', '1',

ts
import { validate } from "robust-validator";
+isBetween(3, 1, 10);
RuleValueIs valid?
between:1,5null🔴
between:1,5undefined🔴
between:1,5'john'🟢
between:1,5'12345'🟢
between:1,5long-text🔴
between:1,512345🔴

boolean

The field under validation must be a boolean value of the form true, false, 0, 1, 'true', 'false', '0', '1',

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { isOpen: "boolean" });
ts
import { validate, boolean } from "robust-validator";
 // ...
 await validate(data, { isOpen: [boolean()] });
ts
import { isBoolean } from "robust-validator";
 // ...
-isBoolean(true);
RuleValueIs valid?
booleannull🔴
booleanundefined🔴
booleantrue🟢
boolean'true'🟢
boolean1🟢
boolean'1'🟢
booleanfalse🔴
boolean'false'🔴
boolean0🔴
boolean'0'🔴

confirmed

The field under validation must have a matching field of foo_confirmation. For example, if the field under validation is password, a matching password_confirmation field must be present in the input.

Let's assume that the value of the password field is 123456. If you use the confirmed definition on the password field's rules, the truth table would look like the following example:

ts
import { validate } from "robust-validator";
+isBoolean(true);
RuleValueIs valid?
booleannull🔴
booleanundefined🔴
booleantrue🟢
boolean'true'🟢
boolean1🟢
boolean'1'🟢
booleanfalse🔴
boolean'false'🔴
boolean0🔴
boolean'0'🔴

confirmed

The field under validation must have a matching field of foo_confirmation. For example, if the field under validation is password, a matching password_confirmation field must be present in the input.

Let's assume that the value of the password field is 123456. If you use the confirmed definition on the password field's rules, the truth table would look like the following example:

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { password: "confirmed" });
ts
import { validate, confirmed } from "robust-validator";
 // ...
 await validate(data, { password: [confirmed()] });
ts
import { isConfirmed } from "robust-validator";
 // ...
-isConfirmed("your-data");
FieldValueIs valid?
password_confirmation123456🟢
password_confirmation654321🔴
password_confirmationnull🔴
password_confirmationundefined🔴
password_confirmationtrue🔴
password_confirmationfalse🔴
password_confirmation{}🔴

date:format

The field under validation must be a valid date format which is acceptable by Javascript's Date object.

ts
import { validate } from "robust-validator";
+isConfirmed("your-data");
FieldValueIs valid?
password_confirmation123456🟢
password_confirmation654321🔴
password_confirmationnull🔴
password_confirmationundefined🔴
password_confirmationtrue🔴
password_confirmationfalse🔴
password_confirmation{}🔴

date:format

The field under validation must be a valid date format which is acceptable by Javascript's Date object.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { startAt: "date:YYYY-MM-DD" });
ts
import { validate, date } from "robust-validator";
 // ...
 await validate(data, { startAt: [date("YYYY-MM-DD")] });
ts
import { isDate } from "robust-validator";
 // ...
-isDate("your-data", "YYYY-MM-DD");
RuleValueIs valid?
date:YYYY-MM-DDnull🔴
date:YYYY-MM-DDundefined🔴
date:YYYY-MM-DD2023-12-16🟢
date:YYYY-MM-DD2023-01-01🟢
date:YYYY-MM-DDDecember 16, 2023 12:00:00🔴
date:YYYY-MM-DD2022-13-01🔴
date:YYYY-MM-DD2022-12-32🔴
date:YYYY-MM-DD2022-02-29🔴
date:YYYY-MM-DDfalse🔴

digits:value

The field under validation must be numeric and must have an exact length of value.

ts
import { validate } from "robust-validator";
+isDate("your-data", "YYYY-MM-DD");
RuleValueIs valid?
date:YYYY-MM-DDnull🔴
date:YYYY-MM-DDundefined🔴
date:YYYY-MM-DD2023-12-16🟢
date:YYYY-MM-DD2023-01-01🟢
date:YYYY-MM-DDDecember 16, 2023 12:00:00🔴
date:YYYY-MM-DD2022-13-01🔴
date:YYYY-MM-DD2022-12-32🔴
date:YYYY-MM-DD2022-02-29🔴
date:YYYY-MM-DDfalse🔴

digits:value

The field under validation must be numeric and must have an exact length of value.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { pin: "digits:4" });
ts
import { validate, digits } from "robust-validator";
 // ...
 await validate(data, { pin: [digits(4)] });
ts
import { isDigits } from "robust-validator";
 // ...
-isDigits("1234", 4);
RuleValueIs valid?
digits:4null🔴
digits:4undefined🔴
digits:41234🟢
digits:4123🔴
digits:4true🔴
digits:4'1234'🔴
digits:4123456🔴

digits_between:min,max

The field under validation must be numeric and must have length between given min and max.

ts
import { validate } from "robust-validator";
+isDigits("1234", 4);
RuleValueIs valid?
digits:4null🔴
digits:4undefined🔴
digits:41234🟢
digits:4123🔴
digits:4true🔴
digits:4'1234'🔴
digits:4123456🔴

digits_between:min,max

The field under validation must be numeric and must have length between given min and max.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { pin: "digits_between:4,6" });
ts
import { validate, digitsBetween } from "robust-validator";
 // ...
 await validate(data, { pin: [digitsBetween(4, 6)] });
ts
import { isdigitsBetween } from "robust-validator";
 // ...
-isdigitsBetween("1234", 4, 6);
RuleValueIs valid?
digits_between:4,6null🔴
digits_between:4,6undefined🔴
digits_between:4,61234🟢
digits_between:4,6123456🟢
digits_between:4,6123🔴
digits_between:4,6true🔴
digits_between:4,6'1234'🔴

email

The field under validation must be formatted as an e-mail address.

ts
import { validate } from "robust-validator";
+isdigitsBetween("1234", 4, 6);
RuleValueIs valid?
digits_between:4,6null🔴
digits_between:4,6undefined🔴
digits_between:4,61234🟢
digits_between:4,6123456🟢
digits_between:4,6123🔴
digits_between:4,6true🔴
digits_between:4,6'1234'🔴

email

The field under validation must be formatted as an e-mail address.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { contact_email: "email" });
ts
import { validate, email } from "robust-validator";
 // ...
 await validate(data, { contact_email: [email()] });
ts
import { isEmail } from "robust-validator";
 // ...
-isEmail("your-date");
RuleValueIs valid?
emailnull🔴
emailundefined🔴
emailfoo@bar.com🟢
emailjust a text🔴
emailtrue🔴
email'1234'🔴

hex

The field under validation should be a hexadecimal format.

ts
import { validate } from "robust-validator";
+isEmail("your-date");
RuleValueIs valid?
emailnull🔴
emailundefined🔴
emailfoo@bar.com🟢
emailjust a text🔴
emailtrue🔴
email'1234'🔴

hex

The field under validation should be a hexadecimal format.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { colorCode: "hex" });
ts
import { validate, hex } from "robust-validator";
 // ...
 await validate(data, { colorCode: [hex()] });
ts
import { isHex } from "robust-validator";
 // ...
-isHex("f1f1f1");
RuleValueIs valid?
hexnull🔴
hexundefined🔴
hex1aF🟢
hex1234567890ABCDEF🟢
hex123xyz🔴
hex0xg🔴
hexinvalid string🔴

in:foo,bar,...

The field under validation must be included in the given list of values.

ts
import { validate } from "robust-validator";
+isHex("f1f1f1");
RuleValueIs valid?
hexnull🔴
hexundefined🔴
hex1aF🟢
hex1234567890ABCDEF🟢
hex123xyz🔴
hex0xg🔴
hexinvalid string🔴

in:foo,bar,...

The field under validation must be included in the given list of values.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { userChoice: "in:news,marketing" });
ts
import { validate, in } from "robust-validator";
 // ...
 await validate(data, { userChoice: [in(["news", "marketing"])] });
ts
import { isIn } from "robust-validator";
 // ...
-isIn("your-data", ["news", "marketing"]);
RuleValueIs valid?
in:A,Bnull🔴
in:A,Bundefined🔴
in:A,BA🟢
in:A,BB🟢
in:A,BC🔴
in:A,Btrue🔴
in:A,B{}🔴

integer

The field under validation must have an integer value.

ts
import { validate } from "robust-validator";
+isIn("your-data", ["news", "marketing"]);
RuleValueIs valid?
in:A,Bnull🔴
in:A,Bundefined🔴
in:A,BA🟢
in:A,BB🟢
in:A,BC🔴
in:A,Btrue🔴
in:A,B{}🔴

integer

The field under validation must have an integer value.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { age: "integer" });
ts
import { validate, integer } from "robust-validator";
 // ...
 await validate(data, { age: [integer()] });
ts
import { isInteger } from "robust-validator";
 // ...
-isInteger(134);
RuleValueIs valid?
integernull🔴
integerundefined🔴
integer123🟢
integer3.14🔴
integerabc🔴

max:value

Validate that an attribute is no greater than a given size

ts
import { validate } from "robust-validator";
+isInteger(134);
RuleValueIs valid?
integernull🔴
integerundefined🔴
integer123🟢
integer3.14🔴
integerabc🔴

max:value

Validate that an attribute is no greater than a given size

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { age: "max:99" });
ts
import { validate, max } from "robust-validator";
 // ...
 await validate(data, { age: [max(99)] });
ts
import { isMax } from "robust-validator";
 // ...
-isMax(10, 99);
RuleValueIs valid?
max:5null🔴
max:5undefined🔴
max:5'123'🟢
max:53🟢
max:5'abcdef'🔴
max:510🔴

min:value

Validate that an attribute is at least a given size.

ts
import { validate } from "robust-validator";
+isMax(10, 99);
RuleValueIs valid?
max:5null🔴
max:5undefined🔴
max:5'123'🟢
max:53🟢
max:5'abcdef'🔴
max:510🔴

min:value

Validate that an attribute is at least a given size.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { age: "min:22" });
ts
import { validate, min } from "robust-validator";
 // ...
 await validate(data, { age: [min(22)] });
ts
import { isMin } from "robust-validator";
 // ...
-isMin(10, 22);
RuleValueIs valid?
min:5null🔴
min:5undefined🔴
min:5'abcdef'🟢
min:5'123456'🟢
min:510🟢
min:5'abcdef'🔴
min:52🔴

not_in:foo,bar,...

The field under validation must not be included in the given list of values.

ts
import { validate } from "robust-validator";
+isMin(10, 22);
RuleValueIs valid?
min:5null🔴
min:5undefined🔴
min:5'abcdef'🟢
min:5'123456'🟢
min:510🟢
min:5'abcdef'🔴
min:52🔴

not_in:foo,bar,...

The field under validation must not be included in the given list of values.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { userChoice: "not_in:news,marketing" });
ts
import { validate, notIn } from "robust-validator";
 // ...
 await validate(data, { userChoice: [notIn(["news", "marketing"])] });
ts
import { isNotIn } from "robust-validator";
 // ...
-isNotIn("your-data", ["news", "marketing"]);
RuleValueIs valid?
not_in:A,Bnull🔴
not_in:A,Bundefined🔴
not_in:A,BC🟢
not_in:A,BA🔴
not_in:A,BB🔴
not_in:A,Btrue🔴

numeric

Validate that an attribute is numeric.

ts
import { validate } from "robust-validator";
+isNotIn("your-data", ["news", "marketing"]);
RuleValueIs valid?
not_in:A,Bnull🔴
not_in:A,Bundefined🔴
not_in:A,BC🟢
not_in:A,BA🔴
not_in:A,BB🔴
not_in:A,Btrue🔴

numeric

Validate that an attribute is numeric.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { salary: "numeric" });
ts
import { validate, numeric } from "robust-validator";
 // ...
 await validate(data, { salary: [numeric()] });
ts
import { isNumeric } from "robust-validator";
 // ...
-isNumeric(3000);
RuleValueIs valid?
integernull🔴
integerundefined🔴
integer123🟢
integer3.14🟢
integerabc🔴

required

Checks if the value is provided.

ts
import { validate } from "robust-validator";
+isNumeric(3000);
RuleValueIs valid?
integernull🔴
integerundefined🔴
integer123🟢
integer3.14🟢
integerabc🔴

required

Checks if the value is provided.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { salary: "required" });
ts
import { validate, required } from "robust-validator";
 // ...
 await validate(data, { salary: [required()] });
ts
import { isRequired } from "robust-validator";
 // ...
-isRequired("your-data");
RuleValueIs valid?
requiredjohn🟢
required123🟢
required1.23🟢
required{}🟢
requirednull🔴
requiredundefined🔴
required''🔴
required' '🔴

size:value

The field under validation must have a size matching the given value. For string data, value corresponds to the number of characters. For numeric data, value corresponds to a given integer value.

ts
import { validate } from "robust-validator";
+isRequired("your-data");
RuleValueIs valid?
requiredjohn🟢
required123🟢
required1.23🟢
required{}🟢
requirednull🔴
requiredundefined🔴
required''🔴
required' '🔴

size:value

The field under validation must have a size matching the given value. For string data, value corresponds to the number of characters. For numeric data, value corresponds to a given integer value.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { password: "size:12" });
ts
import { validate, size } from "robust-validator";
 // ...
 await validate(data, { password: [size(12)] });
ts
import { isSize } from "robust-validator";
 // ...
-isSize("your-data", 12);
RuleValueIs valid?
size:3null🔴
size:3undefined🔴
size:3abc🟢
size:31🟢
size:31.23🟢
size:3abcde🔴
size:310🔴

string

The field under validation must be a string.

ts
import { validate } from "robust-validator";
+isSize("your-data", 12);
RuleValueIs valid?
size:3null🔴
size:3undefined🔴
size:3abc🟢
size:31🟢
size:31.23🟢
size:3abcde🔴
size:310🔴

string

The field under validation must be a string.

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { content: "string" });
ts
import { validate, string } from "robust-validator";
 // ...
 await validate(data, { content: [string()] });
ts
import { isString } from "robust-validator";
 // ...
-isString("your-data");
RuleValueIs valid?
stringabc🟢
string''🟢
string' '🟢
string1🔴
string1.23🔴
stringabcde🔴
string10🔴
stringnull🔴
stringundefined🔴

url

Validate that an attribute has a valid URL format

ts
import { validate } from "robust-validator";
+isString("your-data");
RuleValueIs valid?
stringabc🟢
string''🟢
string' '🟢
string1🔴
string1.23🔴
stringabcde🔴
string10🔴
stringnull🔴
stringundefined🔴

url

Validate that an attribute has a valid URL format

ts
import { validate } from "robust-validator";
 // ...
 await validate(data, { profile: "url" });
ts
import { validate, url } from "robust-validator";
 // ...
 await validate(data, { profile: [url()] });
ts
import { isUrl } from "robust-validator";
 // ...
 isUrl("https://axe-api-com");
RuleValueIs valid?
urlnull🔴
urlundefined🔴
urlhttps://example.com🟢
urlhttp://example.com🟢
urlftp://example.com🟢
urlinvalid-url🔴

Released under the MIT License.

- + \ No newline at end of file diff --git a/sitemap.xml b/sitemap.xml index f36b4cb..20be0ce 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -1 +1 @@ -https://validator.axe-api.com/api-examples.html2024-01-08T17:11:19.814Zhttps://validator.axe-api.com/customization.html2024-01-08T17:11:19.814Zhttps://validator.axe-api.com/examples.html2024-01-08T17:11:19.814Zhttps://validator.axe-api.com/getting-started.html2024-01-08T17:11:19.814Zhttps://validator.axe-api.com/i18n.html2024-01-08T17:11:19.814Zhttps://validator.axe-api.com/2024-01-08T17:11:19.814Zhttps://validator.axe-api.com/options.html2024-01-08T17:11:19.814Zhttps://validator.axe-api.com/terminology.html2024-01-08T17:11:19.818Zhttps://validator.axe-api.com/rules.html2024-01-08T17:11:19.818Zhttps://validator.axe-api.com/why.html2024-01-08T17:11:19.818Z \ No newline at end of file +https://validator.axe-api.com/api-examples.html2024-01-08T17:11:34.411Zhttps://validator.axe-api.com/customization.html2024-01-08T17:11:34.411Zhttps://validator.axe-api.com/examples.html2024-01-08T17:11:34.411Zhttps://validator.axe-api.com/i18n.html2024-01-08T17:11:34.411Zhttps://validator.axe-api.com/getting-started.html2024-01-08T17:11:34.411Zhttps://validator.axe-api.com/2024-01-08T17:11:34.411Zhttps://validator.axe-api.com/options.html2024-01-08T17:11:34.411Zhttps://validator.axe-api.com/rules.html2024-01-08T17:11:34.415Zhttps://validator.axe-api.com/terminology.html2024-01-08T17:11:34.415Zhttps://validator.axe-api.com/why.html2024-01-08T17:11:34.415Z \ No newline at end of file diff --git a/terminology.html b/terminology.html index f9cb937..bf70083 100644 --- a/terminology.html +++ b/terminology.html @@ -30,7 +30,7 @@ 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 after the : operator. If there is more than one parameter, they must be separated using commas.

required|min:1|max:50|between:1,50

Released under the MIT License.

- + \ No newline at end of file diff --git a/why.html b/why.html index d896a2b..ce1162b 100644 --- a/why.html +++ b/why.html @@ -18,7 +18,7 @@
Skip to content

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.

Released under the MIT License.

- + \ No newline at end of file