diff --git a/404.html b/404.html index 3435f87..3804d4a 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 2ec0fdc..5a9772c 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/app.kyHz5Feq.js b/assets/app.kyHz5Feq.js index 45953b5..f42a40d 100644 --- a/assets/app.kyHz5Feq.js +++ b/assets/app.kyHz5Feq.js @@ -4,4 +4,4 @@ function __vite__mapDeps(indexes) { __vite__mapDeps.viteFileDeps = [] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) -} \ No newline at end of file +} diff --git a/assets/chunks/VPLocalSearchBox.lKSclQrs.js b/assets/chunks/VPLocalSearchBox.lKSclQrs.js index 7891c90..cb178a9 100644 --- a/assets/chunks/VPLocalSearchBox.lKSclQrs.js +++ b/assets/chunks/VPLocalSearchBox.lKSclQrs.js @@ -10,4 +10,4 @@ function __vite__mapDeps(indexes) { __vite__mapDeps.viteFileDeps = [] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) -} \ No newline at end of file +} diff --git a/assets/chunks/theme._9xVzK2w.js b/assets/chunks/theme._9xVzK2w.js index d0ba1cb..254fe5a 100644 --- a/assets/chunks/theme._9xVzK2w.js +++ b/assets/chunks/theme._9xVzK2w.js @@ -4,4 +4,4 @@ function __vite__mapDeps(indexes) { __vite__mapDeps.viteFileDeps = ["assets/chunks/VPLocalSearchBox.lKSclQrs.js","assets/chunks/framework.FghLVCew.js"] } return indexes.map((i) => __vite__mapDeps.viteFileDeps[i]) -} \ No newline at end of file +} diff --git a/assets/examples.md.3fha69gO.js b/assets/examples.md.jNPhaiBe.js similarity index 96% rename from assets/examples.md.3fha69gO.js rename to assets/examples.md.jNPhaiBe.js index 21c4b31..22a8078 100644 --- a/assets/examples.md.3fha69gO.js +++ b/assets/examples.md.jNPhaiBe.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"},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{_ 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 { 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),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}; +});
`,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}; diff --git a/assets/examples.md.3fha69gO.lean.js b/assets/examples.md.jNPhaiBe.lean.js similarity index 65% rename from assets/examples.md.3fha69gO.lean.js rename to assets/examples.md.jNPhaiBe.lean.js index 5cf9d14..e9388ab 100644 --- a/assets/examples.md.3fha69gO.lean.js +++ b/assets/examples.md.jNPhaiBe.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"},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}; +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}; diff --git a/assets/getting-started.md.57YtXQfL.js b/assets/getting-started.md.wfeflYW_.js similarity index 98% rename from assets/getting-started.md.57YtXQfL.js rename to assets/getting-started.md.wfeflYW_.js index c9929f5..c802359 100644 --- a/assets/getting-started.md.57YtXQfL.js +++ b/assets/getting-started.md.wfeflYW_.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.57YtXQfL.lean.js b/assets/getting-started.md.wfeflYW_.lean.js
similarity index 100%
rename from assets/getting-started.md.57YtXQfL.lean.js
rename to assets/getting-started.md.wfeflYW_.lean.js
diff --git a/assets/rules.md.OL7v00-N.js b/assets/rules.md.sw-KIpCj.js
similarity index 93%
rename from assets/rules.md.OL7v00-N.js
rename to assets/rules.md.sw-KIpCj.js
index 01ada4b..4228a41 100644
--- a/assets/rules.md.OL7v00-N.js
+++ b/assets/rules.md.sw-KIpCj.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.OL7v00-N.lean.js b/assets/rules.md.sw-KIpCj.lean.js
similarity index 100%
rename from assets/rules.md.OL7v00-N.lean.js
rename to assets/rules.md.sw-KIpCj.lean.js
diff --git a/customization.html b/customization.html
index 253c5f1..08a3075 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 19ea852..d488845 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 e034f3d..2e06358 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 a2ac93c..18c5c92 100644 --- a/hashmap.json +++ b/hashmap.json @@ -1 +1 @@ -{"options.md":"J8mPoffA","customization.md":"LLNYVo54","api-examples.md":"wOFSxzQq","getting-started.md":"57YtXQfL","index.md":"oGu1lJgi","terminology.md":"MCStHf-x","why.md":"a8Yr0n_9","rules.md":"OL7v00-N","examples.md":"3fha69gO","i18n.md":"OMJQmP09"} +{"index.md":"oGu1lJgi","why.md":"a8Yr0n_9","getting-started.md":"wfeflYW_","i18n.md":"OMJQmP09","examples.md":"jNPhaiBe","terminology.md":"MCStHf-x","options.md":"J8mPoffA","customization.md":"LLNYVo54","rules.md":"sw-KIpCj","api-examples.md":"wOFSxzQq"} diff --git a/i18n.html b/i18n.html index 108c728..7def190 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 33c7f29..52f7a40 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 e6cdc30..bced70d 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 d2cfb13..fefec67 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 2efed73..7aeb270 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -1 +1 @@ -https://validator.axe-api.com/api-examples.html2024-01-29T16:08:21.418Zhttps://validator.axe-api.com/customization.html2024-01-29T16:08:21.418Zhttps://validator.axe-api.com/examples.html2024-01-29T16:08:21.418Zhttps://validator.axe-api.com/getting-started.html2024-01-29T16:08:21.418Zhttps://validator.axe-api.com/i18n.html2024-01-29T16:08:21.418Zhttps://validator.axe-api.com/2024-01-29T16:08:21.418Zhttps://validator.axe-api.com/options.html2024-01-29T16:08:21.418Zhttps://validator.axe-api.com/rules.html2024-01-29T16:08:21.422Zhttps://validator.axe-api.com/terminology.html2024-01-29T16:08:21.422Zhttps://validator.axe-api.com/why.html2024-01-29T16:08:21.422Z \ No newline at end of file +https://validator.axe-api.com/customization.html2024-02-07T20:27:29.221Zhttps://validator.axe-api.com/api-examples.html2024-02-07T20:27:29.221Zhttps://validator.axe-api.com/examples.html2024-02-07T20:27:29.221Zhttps://validator.axe-api.com/getting-started.html2024-02-07T20:27:29.221Zhttps://validator.axe-api.com/i18n.html2024-02-07T20:27:29.221Zhttps://validator.axe-api.com/2024-02-07T20:27:29.221Zhttps://validator.axe-api.com/options.html2024-02-07T20:27:29.221Zhttps://validator.axe-api.com/rules.html2024-02-07T20:27:29.221Zhttps://validator.axe-api.com/terminology.html2024-02-07T20:27:29.221Zhttps://validator.axe-api.com/why.html2024-02-07T20:27:29.221Z \ No newline at end of file diff --git a/terminology.html b/terminology.html index e7b5bde..79a4e96 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 7a955be..7a8ac17 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