-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrules.html
186 lines (184 loc) Β· 152 KB
/
rules.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Rules | Robust Validator</title>
<meta name="description" content="Another data validation library">
<meta name="generator" content="VitePress v1.0.0-rc.32">
<link rel="preload stylesheet" href="/assets/style.BfCMp2bG.css" as="style">
<script type="module" src="/assets/app.D4E3cZaz.js"></script>
<link rel="preload" href="/assets/inter-roman-latin.Bu8hRsVA.woff2" as="font" type="font/woff2" crossorigin="">
<link rel="modulepreload" href="/assets/chunks/theme.D_iCQNuL.js">
<link rel="modulepreload" href="/assets/chunks/framework.CAothSqJ.js">
<link rel="modulepreload" href="/assets/rules.md.BNE2Opk6.lean.js">
<script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
<script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
</head>
<body>
<div id="app"><div class="Layout" data-v-9d8abc1e><!--[--><!--]--><!--[--><span tabindex="-1" data-v-c8291ffa></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-c8291ffa> Skip to content </a><!--]--><!----><header class="VPNav" data-v-9d8abc1e data-v-7ad780c2><div class="VPNavBar has-sidebar" data-v-7ad780c2 data-v-5befd255><div class="container" data-v-5befd255><div class="title" data-v-5befd255><div class="VPNavBarTitle has-sidebar" data-v-5befd255 data-v-2973dbb4><a class="title" href="/" data-v-2973dbb4><!--[--><!--]--><!----><!--[-->Robust Validator<!--]--><!--[--><!--]--></a></div></div><div class="content" data-v-5befd255><div class="curtain" data-v-5befd255></div><div class="content-body" data-v-5befd255><!--[--><!--]--><div class="VPNavBarSearch search" data-v-5befd255><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg class="DocSearch-Search-Icon" width="20" height="20" viewBox="0 0 20 20" aria-label="search icon"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-5befd255 data-v-f732b5d0><span id="main-nav-aria-label" class="visually-hidden" data-v-f732b5d0>Main Navigation</span><!--[--><!--[--><a class="VPLink link vp-external-link-icon VPNavBarMenuLink" href="https://validator.axe-api.com/demo" target="_blank" rel="noreferrer" tabindex="0" data-v-f732b5d0 data-v-cb318fec><!--[--><span data-v-cb318fec>Demo</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-5befd255 data-v-283b26e9><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="Switch to dark theme" aria-checked="false" data-v-283b26e9 data-v-70af5d02 data-v-1c29e291><span class="check" data-v-1c29e291><span class="icon" data-v-1c29e291><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-70af5d02><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-70af5d02><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-5befd255 data-v-ef6192dc data-v-e71e869c><!--[--><a class="VPSocialLink no-icon" href="https://github.com/axe-api/validator" aria-label="github" target="_blank" rel="noopener" data-v-e71e869c data-v-16cf740a><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-5befd255 data-v-8e87c032 data-v-aa8de344><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-aa8de344><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="icon" data-v-aa8de344><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="5" cy="12" r="2"></circle></svg></button><div class="menu" data-v-aa8de344><div class="VPMenu" data-v-aa8de344 data-v-e42ed9b3><!----><!--[--><!--[--><!----><div class="group" data-v-8e87c032><div class="item appearance" data-v-8e87c032><p class="label" data-v-8e87c032>Appearance</p><div class="appearance-action" data-v-8e87c032><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="Switch to dark theme" aria-checked="false" data-v-8e87c032 data-v-70af5d02 data-v-1c29e291><span class="check" data-v-1c29e291><span class="icon" data-v-1c29e291><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-70af5d02><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-70af5d02><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div></div></div><div class="group" data-v-8e87c032><div class="item social-links" data-v-8e87c032><div class="VPSocialLinks social-links-list" data-v-8e87c032 data-v-e71e869c><!--[--><a class="VPSocialLink no-icon" href="https://github.com/axe-api/validator" aria-label="github" target="_blank" rel="noopener" data-v-e71e869c data-v-16cf740a><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-5befd255 data-v-6bee1efd><span class="container" data-v-6bee1efd><span class="top" data-v-6bee1efd></span><span class="middle" data-v-6bee1efd></span><span class="bottom" data-v-6bee1efd></span></span></button></div></div></div></div><!----></header><div class="VPLocalNav reached-top" data-v-9d8abc1e data-v-f8a0b38a><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-f8a0b38a><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="menu-icon" data-v-f8a0b38a><path d="M17,11H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,11,17,11z"></path><path d="M21,7H3C2.4,7,2,6.6,2,6s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,7,21,7z"></path><path d="M21,15H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,15,21,15z"></path><path d="M17,19H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,19,17,19z"></path></svg><span class="menu-text" data-v-f8a0b38a>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-f8a0b38a data-v-24251f6f><button data-v-24251f6f>Return to top</button><!----></div></div><aside class="VPSidebar" data-v-9d8abc1e data-v-168699b1><div class="curtain" data-v-168699b1></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-168699b1><span class="visually-hidden" id="sidebar-aria-label" data-v-168699b1> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="group" data-v-168699b1><section class="VPSidebarItem level-0" data-v-168699b1 data-v-bd01e0d5><div class="item" role="button" tabindex="0" data-v-bd01e0d5><div class="indicator" data-v-bd01e0d5></div><h2 class="text" data-v-bd01e0d5>Introduction</h2><!----></div><div class="items" data-v-bd01e0d5><!--[--><div class="VPSidebarItem level-1 is-link" data-v-bd01e0d5 data-v-bd01e0d5><div class="item" data-v-bd01e0d5><div class="indicator" data-v-bd01e0d5></div><a class="VPLink link link" href="/why.html" data-v-bd01e0d5><!--[--><p class="text" data-v-bd01e0d5>Why?</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-bd01e0d5 data-v-bd01e0d5><div class="item" data-v-bd01e0d5><div class="indicator" data-v-bd01e0d5></div><a class="VPLink link link" href="/getting-started.html" data-v-bd01e0d5><!--[--><p class="text" data-v-bd01e0d5>Getting started</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-bd01e0d5 data-v-bd01e0d5><div class="item" data-v-bd01e0d5><div class="indicator" data-v-bd01e0d5></div><a class="VPLink link link" href="/examples.html" data-v-bd01e0d5><!--[--><p class="text" data-v-bd01e0d5>Examples</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-bd01e0d5 data-v-bd01e0d5><div class="item" data-v-bd01e0d5><div class="indicator" data-v-bd01e0d5></div><a class="VPLink link link" href="/terminology.html" data-v-bd01e0d5><!--[--><p class="text" data-v-bd01e0d5>Terminology</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-168699b1><section class="VPSidebarItem level-0 has-active" data-v-168699b1 data-v-bd01e0d5><div class="item" role="button" tabindex="0" data-v-bd01e0d5><div class="indicator" data-v-bd01e0d5></div><h2 class="text" data-v-bd01e0d5>Reference</h2><!----></div><div class="items" data-v-bd01e0d5><!--[--><div class="VPSidebarItem level-1 is-link" data-v-bd01e0d5 data-v-bd01e0d5><div class="item" data-v-bd01e0d5><div class="indicator" data-v-bd01e0d5></div><a class="VPLink link link" href="/rules.html" data-v-bd01e0d5><!--[--><p class="text" data-v-bd01e0d5>Rules</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-bd01e0d5 data-v-bd01e0d5><div class="item" data-v-bd01e0d5><div class="indicator" data-v-bd01e0d5></div><a class="VPLink link link" href="/i18n.html" data-v-bd01e0d5><!--[--><p class="text" data-v-bd01e0d5>i18n</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-bd01e0d5 data-v-bd01e0d5><div class="item" data-v-bd01e0d5><div class="indicator" data-v-bd01e0d5></div><a class="VPLink link link" href="/customization.html" data-v-bd01e0d5><!--[--><p class="text" data-v-bd01e0d5>Customization</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-bd01e0d5 data-v-bd01e0d5><div class="item" data-v-bd01e0d5><div class="indicator" data-v-bd01e0d5></div><a class="VPLink link link" href="/options.html" data-v-bd01e0d5><!--[--><p class="text" data-v-bd01e0d5>Options</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-9d8abc1e data-v-3cf691b6><div class="VPDoc has-sidebar has-aside" data-v-3cf691b6 data-v-a3c25e27><!--[--><!--]--><div class="container" data-v-a3c25e27><div class="aside" data-v-a3c25e27><div class="aside-curtain" data-v-a3c25e27></div><div class="aside-container" data-v-a3c25e27><div class="aside-content" data-v-a3c25e27><div class="VPDocAside" data-v-a3c25e27 data-v-cb998dce><!--[--><!--]--><!--[--><!--]--><div class="VPDocAsideOutline" role="navigation" data-v-cb998dce data-v-3a6c4994><div class="content" data-v-3a6c4994><div class="outline-marker" data-v-3a6c4994></div><div class="outline-title" role="heading" aria-level="2" data-v-3a6c4994>On this page</div><nav aria-labelledby="doc-outline-aria-label" data-v-3a6c4994><span class="visually-hidden" id="doc-outline-aria-label" data-v-3a6c4994> Table of Contents for current page </span><ul class="root" data-v-3a6c4994 data-v-463da30f><!--[--><!--]--></ul></nav></div></div><!--[--><!--]--><div class="spacer" data-v-cb998dce></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-a3c25e27><div class="content-container" data-v-a3c25e27><!--[--><!--]--><!----><main class="main" data-v-a3c25e27><div style="position:relative;" class="vp-doc _rules" data-v-a3c25e27><div><h1 id="rules" tabindex="-1">Rules <a class="header-anchor" href="#rules" aria-label="Permalink to "Rules"">β</a></h1><p>In this section, you can find the truth tables for all validation rules.</p><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>You can learn more about the <a href="/terminology.html#rule">Rule Terminology</a>.</p></div><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p>Each rule function should validate only one thing. For example, the <code>email</code> validation <strong>should NOT</strong> check if the data is provided. Otherwise, a rule function can not check the optional data.</p><p>That's why <code>null</code> and <code>undefined</code> values are acceptable for all rules except the <code>required</code>.</p><p>If you want to check if the data is provided and is a valid email, you should use two rules (<code>required</code>, <code>email</code>) at the same time.</p></div><h2 id="accepted" tabindex="-1"><code>accepted</code> <a class="header-anchor" href="#accepted" aria-label="Permalink to "`accepted`"">β</a></h2><p>The field under validation must be <code>yes</code>, <code>on</code>, <code>1</code> or <code>true</code>. This is useful for validating "Terms of Service" acceptance.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-2evHi" id="tab-Rl5M5so" checked="checked"><label for="tab-Rl5M5so">Declarative</label><input type="radio" name="group-2evHi" id="tab-X4WMSSQ"><label for="tab-X4WMSSQ">Function-based</label><input type="radio" name="group-2evHi" id="tab-7HlBAfL"><label for="tab-7HlBAfL">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { terms: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"accepted"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, accepted } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { terms: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">accepted</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isAccepted } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isAccepted</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"your-value"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>accepted</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>accepted</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>accepted</code></td><td><code>'yes'</code></td><td>π’</td></tr><tr><td><code>accepted</code></td><td><code>'on'</code></td><td>π’</td></tr><tr><td><code>accepted</code></td><td><code>1</code></td><td>π’</td></tr><tr><td><code>accepted</code></td><td><code>true</code></td><td>π’</td></tr><tr><td><code>accepted</code></td><td><code>john</code></td><td>π΄</td></tr><tr><td><code>accepted</code></td><td><code>3.14</code></td><td>π΄</td></tr></tbody></table><h2 id="after-date" tabindex="-1"><code>after:date</code> <a class="header-anchor" href="#after-date" aria-label="Permalink to "`after:date`"">β</a></h2><p>The field under validation must be after the given date.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-3ansH" id="tab-sl9RSN2" checked="checked"><label for="tab-sl9RSN2">Declarative</label><input type="radio" name="group-3ansH" id="tab-5sm8rSe"><label for="tab-5sm8rSe">Function-based</label><input type="radio" name="group-3ansH" id="tab-9tB7BoB"><label for="tab-9tB7BoB">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { startAt: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"after:2023-01-01"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, after } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { startAt: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">after</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"2023-01-01"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isAfter } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isAfter</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"your-value"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"2023-01-01"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>robust-validator library uses the <a href="https://date-fns.org" target="_blank" rel="noreferrer">date-fns</a> for the date validations.</p><p>You can check the possible date formats <a href="https://date-fns.org/v4.1.0/docs/format" target="_blank" rel="noreferrer">here</a>.</p></div><table><thead><tr><th>Rule</th><th>Value</th><th><code>startAt</code></th><th>Is valid?</th></tr></thead><tbody><tr><td><code>after:2024-01-01</code></td><td><code>null</code></td><td></td><td>π΄</td></tr><tr><td><code>after:2024-01-01</code></td><td><code>undefined</code></td><td></td><td>π΄</td></tr><tr><td><code>after:2024-01-01</code></td><td><code>2025-01-01</code></td><td></td><td>π’</td></tr><tr><td><code>after:startAt</code></td><td><code>2025-01-01</code></td><td><code>2024-01-01</code></td><td>π’</td></tr><tr><td><code>after:startAt</code></td><td><code>2024-01-01</code></td><td><code>2024-01-01</code></td><td>π΄</td></tr><tr><td><code>after:startAt</code></td><td><code>2024-01-01</code></td><td><code>2025-01-01</code></td><td>π΄</td></tr><tr><td><code>after:2024-01-01</code></td><td><code>2024-01-01</code></td><td></td><td>π΄</td></tr><tr><td><code>after:2024-01-01</code></td><td><code>2020-01-01</code></td><td></td><td>π΄</td></tr></tbody></table><h2 id="after-or-equal-date" tabindex="-1"><code>after_or_equal:date</code> <a class="header-anchor" href="#after-or-equal-date" aria-label="Permalink to "`after_or_equal:date`"">β</a></h2><p>The field unter validation must be after or equal to the given field</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-cOhEx" id="tab-6Bzzct8" checked="checked"><label for="tab-6Bzzct8">Declarative</label><input type="radio" name="group-cOhEx" id="tab-QmTx8_q"><label for="tab-QmTx8_q">Function-based</label><input type="radio" name="group-cOhEx" id="tab-vvpCs6S"><label for="tab-vvpCs6S">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { startAt: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"after_or_equal:2023-01-01"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, afterOrEqual } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { startAt: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">afterOrEqual</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"2023-01-01"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isAfterOrEqual } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isAfterOrEqual</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"your-value"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"2023-01-01"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>robust-validator library uses the <a href="https://date-fns.org" target="_blank" rel="noreferrer">date-fns</a> for the date validations.</p><p>You can check the possible date formats <a href="https://date-fns.org/v4.1.0/docs/format" target="_blank" rel="noreferrer">here</a>.</p></div><table><thead><tr><th>Rule</th><th>Value</th><th><code>startAt</code></th><th>Is valid?</th></tr></thead><tbody><tr><td><code>after_or_equal:2024-01-01</code></td><td><code>null</code></td><td></td><td>π΄</td></tr><tr><td><code>after_or_equal:2024-01-01</code></td><td><code>undefined</code></td><td></td><td>π΄</td></tr><tr><td><code>after_or_equal:2024-01-01</code></td><td><code>2025-01-01</code></td><td></td><td>π’</td></tr><tr><td><code>after_or_equal:2024-01-01</code></td><td><code>2024-01-01</code></td><td></td><td>π’</td></tr><tr><td><code>after_or_equal:startAt</code></td><td><code>2025-01-01</code></td><td><code>2024-01-01</code></td><td>π’</td></tr><tr><td><code>after_or_equal:startAt</code></td><td><code>2024-01-01</code></td><td><code>2024-01-01</code></td><td>π’</td></tr><tr><td><code>after_or_equal:startAt</code></td><td><code>2024-01-01</code></td><td><code>2025-01-01</code></td><td>π΄</td></tr><tr><td><code>after_or_equal:2024-01-01</code></td><td><code>2020-01-01</code></td><td></td><td>π΄</td></tr></tbody></table><h2 id="alpha" tabindex="-1"><code>alpha</code> <a class="header-anchor" href="#alpha" aria-label="Permalink to "`alpha`"">β</a></h2><p>The field under validation must be entirely alphabetic characters.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-ku7aZ" id="tab--kR1NMx" checked="checked"><label for="tab--kR1NMx">Declarative</label><input type="radio" name="group-ku7aZ" id="tab-YGBEdJm"><label for="tab-YGBEdJm">Function-based</label><input type="radio" name="group-ku7aZ" id="tab-Ex4CcHv"><label for="tab-Ex4CcHv">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { username: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"alpha"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, alpha } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { username: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">alpha</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isAlpha } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isAlpha</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"your-value"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>alpha</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>alpha</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>alpha</code></td><td><code>john</code></td><td>π’</td></tr><tr><td><code>alpha</code></td><td><code>john123</code></td><td>π΄</td></tr><tr><td><code>alpha</code></td><td><code>john-doe</code></td><td>π΄</td></tr><tr><td><code>alpha</code></td><td><code>123</code></td><td>π΄</td></tr><tr><td><code>alpha</code></td><td><code>3.14</code></td><td>π΄</td></tr><tr><td><code>alpha</code></td><td><code>true</code></td><td>π΄</td></tr></tbody></table><h2 id="alpha-dash" tabindex="-1"><code>alpha_dash</code> <a class="header-anchor" href="#alpha-dash" aria-label="Permalink to "`alpha_dash`"">β</a></h2><p>The field under validation may have alpha-numeric characters, as well as dashes and underscores.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-_l0VF" id="tab-O6xPB_l" checked="checked"><label for="tab-O6xPB_l">Declarative</label><input type="radio" name="group-_l0VF" id="tab-TLY1fe_"><label for="tab-TLY1fe_">Function-based</label><input type="radio" name="group-_l0VF" id="tab-_dJFBzN"><label for="tab-_dJFBzN">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { username: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"alpha_dash"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, alphaDash } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { username: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">alphaDash</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isAlphaDash } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isAlphaDash</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"your-value"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>alpha_dash</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>alpha_dash</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>alpha_dash</code></td><td><code>john</code></td><td>π’</td></tr><tr><td><code>alpha_dash</code></td><td><code>john-doe</code></td><td>π’</td></tr><tr><td><code>alpha_dash</code></td><td><code>john_doe</code></td><td>π’</td></tr><tr><td><code>alpha_dash</code></td><td><code>john123</code></td><td>π΄</td></tr><tr><td><code>alpha_dash</code></td><td><code>123</code></td><td>π΄</td></tr><tr><td><code>alpha_dash</code></td><td><code>3.14</code></td><td>π΄</td></tr><tr><td><code>alpha_dash</code></td><td><code>true</code></td><td>π΄</td></tr></tbody></table><h2 id="alpha-num" tabindex="-1"><code>alpha_num</code> <a class="header-anchor" href="#alpha-num" aria-label="Permalink to "`alpha_num`"">β</a></h2><p>The field under validation must be entirely alpha-numeric characters.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-BGTzE" id="tab-yMqLk5L" checked="checked"><label for="tab-yMqLk5L">Declarative</label><input type="radio" name="group-BGTzE" id="tab-N6sFyd1"><label for="tab-N6sFyd1">Function-based</label><input type="radio" name="group-BGTzE" id="tab-IQ0JPbA"><label for="tab-IQ0JPbA">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { username: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"alpha_num"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, alphaNum } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { username: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">alphaNum</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isAlphaNum } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isAlphaNum</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"your-value"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>alpha_num</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>alpha_num</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>alpha_num</code></td><td><code>john</code></td><td>π’</td></tr><tr><td><code>alpha_num</code></td><td><code>john123</code></td><td>π’</td></tr><tr><td><code>alpha_num</code></td><td><code>john-doe</code></td><td>π΄</td></tr><tr><td><code>alpha_num</code></td><td><code>john_doe</code></td><td>π΄</td></tr><tr><td><code>alpha_num</code></td><td><code>123</code></td><td>π΄</td></tr><tr><td><code>alpha_num</code></td><td><code>3.14</code></td><td>π΄</td></tr><tr><td><code>alpha_num</code></td><td><code>true</code></td><td>π΄</td></tr></tbody></table><h2 id="array" tabindex="-1"><code>array</code> <a class="header-anchor" href="#array" aria-label="Permalink to "`array`"">β</a></h2><p>The field under validation must be an array.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-PMS-s" id="tab-D2ufQ3Y" checked="checked"><label for="tab-D2ufQ3Y">Declarative</label><input type="radio" name="group-PMS-s" id="tab-Mtk2ozB"><label for="tab-Mtk2ozB">Function-based</label><input type="radio" name="group-PMS-s" id="tab-RjkFT5T"><label for="tab-RjkFT5T">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { selectedIds: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"array"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, array } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { selectedIds: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">array</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isArray } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isArray</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">([</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>array</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>array</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>array</code></td><td><code>[]</code></td><td>π’</td></tr><tr><td><code>array</code></td><td><code>[1, 2, 3]</code></td><td>π’</td></tr><tr><td><code>array</code></td><td><code>[{"id": 1}]</code></td><td>π’</td></tr><tr><td><code>array</code></td><td><code>john</code></td><td>π΄</td></tr><tr><td><code>array</code></td><td><code>john</code></td><td>π΄</td></tr><tr><td><code>array</code></td><td><code>123</code></td><td>π΄</td></tr><tr><td><code>array</code></td><td><code>3.14</code></td><td>π΄</td></tr><tr><td><code>array</code></td><td><code>true</code></td><td>π΄</td></tr></tbody></table><h2 id="before-date" tabindex="-1"><code>before:date</code> <a class="header-anchor" href="#before-date" aria-label="Permalink to "`before:date`"">β</a></h2><p>The field under validation must be before the given date.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-Ez_IT" id="tab-hp73opw" checked="checked"><label for="tab-hp73opw">Declarative</label><input type="radio" name="group-Ez_IT" id="tab-cA_P--4"><label for="tab-cA_P--4">Function-based</label><input type="radio" name="group-Ez_IT" id="tab-jnGpaNF"><label for="tab-jnGpaNF">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { startAt: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"before:2023-01-01"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, before } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { startAt: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">before</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"2023-01-01"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isBefore } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isBefore</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"your-value"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"2023-01-01"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>robust-validator library uses the <a href="https://date-fns.org" target="_blank" rel="noreferrer">date-fns</a> for the date validations.</p><p>You can check the possible date formats <a href="https://date-fns.org/v4.1.0/docs/format" target="_blank" rel="noreferrer">here</a>.</p></div><table><thead><tr><th>Rule</th><th>Value</th><th><code>finishAt</code></th><th>Is valid?</th></tr></thead><tbody><tr><td><code>before:2024-01-01</code></td><td><code>null</code></td><td></td><td>π΄</td></tr><tr><td><code>before:2024-01-01</code></td><td><code>undefined</code></td><td></td><td>π΄</td></tr><tr><td><code>before:2024-01-01</code></td><td><code>2023-01-01</code></td><td></td><td>π’</td></tr><tr><td><code>before:finishAt</code></td><td><code>2023-01-01</code></td><td><code>2024-01-01</code></td><td>π’</td></tr><tr><td><code>before:finishAt</code></td><td><code>2023-01-01</code></td><td><code>2023-01-01</code></td><td>π΄</td></tr><tr><td><code>before:finishAt</code></td><td><code>2023-01-01</code></td><td><code>2022-01-01</code></td><td>π΄</td></tr><tr><td><code>before:2024-01-01</code></td><td><code>2024-01-01</code></td><td></td><td>π΄</td></tr><tr><td><code>before:2024-01-01</code></td><td><code>2025-01-01</code></td><td></td><td>π΄</td></tr></tbody></table><h2 id="before-or-equal-date" tabindex="-1"><code>before_or_equal:date</code> <a class="header-anchor" href="#before-or-equal-date" aria-label="Permalink to "`before_or_equal:date`"">β</a></h2><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-Dgfh2" id="tab-3_GDM1i" checked="checked"><label for="tab-3_GDM1i">Declarative</label><input type="radio" name="group-Dgfh2" id="tab-1YsMIBo"><label for="tab-1YsMIBo">Function-based</label><input type="radio" name="group-Dgfh2" id="tab-8gxeiFn"><label for="tab-8gxeiFn">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { startAt: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"before_or_equal:2023-01-01"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, beforeOrEqual } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { startAt: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">beforeOrEqual</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"2023-01-01"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isBeforeOrEqual } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isBeforeOrEqual</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"your-value"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"2023-01-01"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><p>The field under validation must be before or equal to the given date.</p><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>robust-validator library uses the <a href="https://date-fns.org" target="_blank" rel="noreferrer">date-fns</a> for the date validations.</p><p>You can check the possible date formats <a href="https://date-fns.org/v4.1.0/docs/format" target="_blank" rel="noreferrer">here</a>.</p></div><table><thead><tr><th>Rule</th><th>Value</th><th><code>finishAt</code></th><th>Is valid?</th></tr></thead><tbody><tr><td><code>before_or_equal:2024-01-01</code></td><td><code>null</code></td><td></td><td>π΄</td></tr><tr><td><code>before_or_equal:2024-01-01</code></td><td><code>undefined</code></td><td></td><td>π΄</td></tr><tr><td><code>before_or_equal:2024-01-01</code></td><td><code>2023-01-01</code></td><td></td><td>π’</td></tr><tr><td><code>before_or_equal:2024-01-01</code></td><td><code>2024-01-01</code></td><td></td><td>π’</td></tr><tr><td><code>before_or_equal:finishAt</code></td><td><code>2023-01-01</code></td><td><code>2024-01-01</code></td><td>π’</td></tr><tr><td><code>before_or_equal:finishAt</code></td><td><code>2023-01-01</code></td><td><code>2023-01-01</code></td><td>π’</td></tr><tr><td><code>before_or_equal:finishAt</code></td><td><code>2023-01-01</code></td><td><code>2022-01-01</code></td><td>π΄</td></tr><tr><td><code>before_or_equal:2024-01-01</code></td><td><code>2025-01-01</code></td><td></td><td>π΄</td></tr></tbody></table><h2 id="between-min-max" tabindex="-1"><code>between:min,max</code> <a class="header-anchor" href="#between-min-max" aria-label="Permalink to "`between:min,max`"">β</a></h2><p>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.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-VJ1cw" id="tab-2X7NFAg" checked="checked"><label for="tab-2X7NFAg">Declarative</label><input type="radio" name="group-VJ1cw" id="tab-uNY8VlV"><label for="tab-uNY8VlV">Function-based</label><input type="radio" name="group-VJ1cw" id="tab-16viEsI"><label for="tab-16viEsI">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { score: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"between:1,10"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, score } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { score: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">score</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">10</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isBetween } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isBetween</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">10</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>between:1,5</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>between:1,5</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>between:1,5</code></td><td><code>'john'</code></td><td>π’</td></tr><tr><td><code>between:1,5</code></td><td><code>'12345'</code></td><td>π’</td></tr><tr><td><code>between:1,5</code></td><td><code>long-text</code></td><td>π΄</td></tr><tr><td><code>between:1,5</code></td><td><code>12345</code></td><td>π΄</td></tr></tbody></table><h2 id="boolean" tabindex="-1"><code>boolean</code> <a class="header-anchor" href="#boolean" aria-label="Permalink to "`boolean`"">β</a></h2><p>The field under validation must be a boolean value of the form true, false, 0, 1, 'true', 'false', '0', '1',</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-27OS9" id="tab-1c3_Xsl" checked="checked"><label for="tab-1c3_Xsl">Declarative</label><input type="radio" name="group-27OS9" id="tab-xEUPCbu"><label for="tab-xEUPCbu">Function-based</label><input type="radio" name="group-27OS9" id="tab-8SOHV2P"><label for="tab-8SOHV2P">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { isOpen: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"boolean"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, boolean } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { isOpen: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">boolean</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isBoolean } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isBoolean</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">true</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>boolean</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>boolean</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>boolean</code></td><td><code>true</code></td><td>π’</td></tr><tr><td><code>boolean</code></td><td><code>'true'</code></td><td>π’</td></tr><tr><td><code>boolean</code></td><td><code>1</code></td><td>π’</td></tr><tr><td><code>boolean</code></td><td><code>'1'</code></td><td>π’</td></tr><tr><td><code>boolean</code></td><td><code>false</code></td><td>π΄</td></tr><tr><td><code>boolean</code></td><td><code>'false'</code></td><td>π΄</td></tr><tr><td><code>boolean</code></td><td><code>0</code></td><td>π΄</td></tr><tr><td><code>boolean</code></td><td><code>'0'</code></td><td>π΄</td></tr></tbody></table><h2 id="confirmed" tabindex="-1"><code>confirmed</code> <a class="header-anchor" href="#confirmed" aria-label="Permalink to "`confirmed`"">β</a></h2><p>The field under validation must have a matching field of <code>foo_confirmed</code>. For example, if the field under validation is <code>password</code>, a matching <code>password_confirmed</code> field must be present in the input.</p><p>Let's assume that the value of the <code>password</code> field is <code>123456</code>. If you use the <code>confirmed</code> definition on the <code>password</code> field's rules, the truth table would look like the following example:</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-MgFZN" id="tab-0zFFO9V" checked="checked"><label for="tab-0zFFO9V">Declarative</label><input type="radio" name="group-MgFZN" id="tab-1VbA6j6"><label for="tab-1VbA6j6">Function-based</label><input type="radio" name="group-MgFZN" id="tab-CmfZPjG"><label for="tab-CmfZPjG">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { password: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"confirmed"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, confirmed } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { password: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">confirmed</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isConfirmed } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isConfirmed</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"your-data"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Field</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>password_confirmed</code></td><td><code>123456</code></td><td>π’</td></tr><tr><td><code>password_confirmed</code></td><td><code>654321</code></td><td>π΄</td></tr><tr><td><code>password_confirmed</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>password_confirmed</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>password_confirmed</code></td><td><code>true</code></td><td>π΄</td></tr><tr><td><code>password_confirmed</code></td><td><code>false</code></td><td>π΄</td></tr><tr><td><code>password_confirmed</code></td><td><code>{}</code></td><td>π΄</td></tr></tbody></table><h2 id="date-format" tabindex="-1"><code>date:format</code> <a class="header-anchor" href="#date-format" aria-label="Permalink to "`date:format`"">β</a></h2><p>The field under validation must be a valid date format which is acceptable by Javascript's Date object.</p><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>robust-validator library uses the <a href="https://date-fns.org" target="_blank" rel="noreferrer">date-fns</a> for the date validations.</p><p>You can check the possible date formats <a href="https://date-fns.org/v4.1.0/docs/format" target="_blank" rel="noreferrer">here</a>.</p></div><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-PHOYJ" id="tab-Kr7w8JX" checked="checked"><label for="tab-Kr7w8JX">Declarative</label><input type="radio" name="group-PHOYJ" id="tab-_blVvEm"><label for="tab-_blVvEm">Function-based</label><input type="radio" name="group-PHOYJ" id="tab-o0LNhHj"><label for="tab-o0LNhHj">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { startAt: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"date:yyyy-MM-dd"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, date } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { startAt: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">date</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"yyyy-MM-dd"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isDate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isDate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"your-data"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"yyyy-MM-dd"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>date:yyyy-MM-dd</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>date:yyyy-MM-dd</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>date:yyyy-MM-dd</code></td><td><code>2023-12-16</code></td><td>π’</td></tr><tr><td><code>date:yyyy-MM-dd</code></td><td><code>2023-01-01</code></td><td>π’</td></tr><tr><td><code>date:yyyy-MM-dd</code></td><td><code>December 16, 2023 12:00:00</code></td><td>π΄</td></tr><tr><td><code>date:yyyy-MM-dd</code></td><td><code>2022-13-01</code></td><td>π΄</td></tr><tr><td><code>date:yyyy-MM-dd</code></td><td><code>2022-12-32</code></td><td>π΄</td></tr><tr><td><code>date:yyyy-MM-dd</code></td><td><code>2022-02-29</code></td><td>π΄</td></tr><tr><td><code>date:yyyy-MM-dd</code></td><td><code>false</code></td><td>π΄</td></tr></tbody></table><h2 id="digits-value" tabindex="-1"><code>digits:value</code> <a class="header-anchor" href="#digits-value" aria-label="Permalink to "`digits:value`"">β</a></h2><p>The field under validation must be numeric and must have an exact length of value.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-PGxn_" id="tab-mi72xbf" checked="checked"><label for="tab-mi72xbf">Declarative</label><input type="radio" name="group-PGxn_" id="tab-pp4AL-B"><label for="tab-pp4AL-B">Function-based</label><input type="radio" name="group-PGxn_" id="tab-QzOH2Fq"><label for="tab-QzOH2Fq">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { pin: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"digits:4"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, digits } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { pin: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">digits</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isDigits } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isDigits</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"1234"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>digits:4</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>digits:4</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>digits:4</code></td><td><code>1234</code></td><td>π’</td></tr><tr><td><code>digits:4</code></td><td><code>123</code></td><td>π΄</td></tr><tr><td><code>digits:4</code></td><td><code>true</code></td><td>π΄</td></tr><tr><td><code>digits:4</code></td><td><code>'1234'</code></td><td>π΄</td></tr><tr><td><code>digits:4</code></td><td><code>123456</code></td><td>π΄</td></tr></tbody></table><h2 id="digits-between-min-max" tabindex="-1"><code>digits_between:min,max</code> <a class="header-anchor" href="#digits-between-min-max" aria-label="Permalink to "`digits_between:min,max`"">β</a></h2><p>The field under validation must be numeric and must have length between given min and max.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-JtT2e" id="tab-UDkIf-c" checked="checked"><label for="tab-UDkIf-c">Declarative</label><input type="radio" name="group-JtT2e" id="tab-xWusuS-"><label for="tab-xWusuS-">Function-based</label><input type="radio" name="group-JtT2e" id="tab-y6nokAK"><label for="tab-y6nokAK">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { pin: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"digits_between:4,6"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, digitsBetween } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { pin: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">digitsBetween</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">6</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isdigitsBetween } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isdigitsBetween</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"1234"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">6</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>digits_between:4,6</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>digits_between:4,6</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>digits_between:4,6</code></td><td><code>1234</code></td><td>π’</td></tr><tr><td><code>digits_between:4,6</code></td><td><code>123456</code></td><td>π’</td></tr><tr><td><code>digits_between:4,6</code></td><td><code>123</code></td><td>π΄</td></tr><tr><td><code>digits_between:4,6</code></td><td><code>true</code></td><td>π΄</td></tr><tr><td><code>digits_between:4,6</code></td><td><code>'1234'</code></td><td>π΄</td></tr></tbody></table><h2 id="email" tabindex="-1"><code>email</code> <a class="header-anchor" href="#email" aria-label="Permalink to "`email`"">β</a></h2><p>The field under validation must be formatted as an e-mail address.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-c-Tmd" id="tab-OyI-Ftu" checked="checked"><label for="tab-OyI-Ftu">Declarative</label><input type="radio" name="group-c-Tmd" id="tab-_P1YpFE"><label for="tab-_P1YpFE">Function-based</label><input type="radio" name="group-c-Tmd" id="tab-bkGH3sy"><label for="tab-bkGH3sy">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { contact_email: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"email"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, email } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { contact_email: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">email</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isEmail } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isEmail</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"your-date"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>email</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>email</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>email</code></td><td><code>[email protected]</code></td><td>π’</td></tr><tr><td><code>email</code></td><td><code>just a text</code></td><td>π΄</td></tr><tr><td><code>email</code></td><td><code>true</code></td><td>π΄</td></tr><tr><td><code>email</code></td><td><code>'1234'</code></td><td>π΄</td></tr></tbody></table><h2 id="hex" tabindex="-1"><code>hex</code> <a class="header-anchor" href="#hex" aria-label="Permalink to "`hex`"">β</a></h2><p>The field under validation should be a hexadecimal format.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-BjauK" id="tab-V5us-3S" checked="checked"><label for="tab-V5us-3S">Declarative</label><input type="radio" name="group-BjauK" id="tab-I19Ghg8"><label for="tab-I19Ghg8">Function-based</label><input type="radio" name="group-BjauK" id="tab-F2oCDAn"><label for="tab-F2oCDAn">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { colorCode: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"hex"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, hex } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { colorCode: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">hex</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isHex } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isHex</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"f1f1f1"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>hex</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>hex</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>hex</code></td><td><code>1aF</code></td><td>π’</td></tr><tr><td><code>hex</code></td><td><code>1234567890ABCDEF</code></td><td>π’</td></tr><tr><td><code>hex</code></td><td><code>123xyz</code></td><td>π΄</td></tr><tr><td><code>hex</code></td><td><code>0xg</code></td><td>π΄</td></tr><tr><td><code>hex</code></td><td><code>invalid string</code></td><td>π΄</td></tr></tbody></table><h2 id="in-foo-bar" tabindex="-1"><code>in:foo,bar,...</code> <a class="header-anchor" href="#in-foo-bar" aria-label="Permalink to "`in:foo,bar,...`"">β</a></h2><p>The field under validation must be included in the given list of values.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-ndh3A" id="tab-mxWJHau" checked="checked"><label for="tab-mxWJHau">Declarative</label><input type="radio" name="group-ndh3A" id="tab-1s1YlHn"><label for="tab-1s1YlHn">Function-based</label><input type="radio" name="group-ndh3A" id="tab-NDGj0LU"><label for="tab-NDGj0LU">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { userChoice: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"in:news,marketing"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, in } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { userChoice: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">([</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"news"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"marketing"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">])] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isIn } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isIn</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"your-data"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, [</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"news"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"marketing"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>in:A,B</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>in:A,B</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>in:A,B</code></td><td><code>A</code></td><td>π’</td></tr><tr><td><code>in:A,B</code></td><td><code>B</code></td><td>π’</td></tr><tr><td><code>in:A,B</code></td><td><code>C</code></td><td>π΄</td></tr><tr><td><code>in:A,B</code></td><td><code>true</code></td><td>π΄</td></tr><tr><td><code>in:A,B</code></td><td><code>{}</code></td><td>π΄</td></tr></tbody></table><h2 id="integer" tabindex="-1"><code>integer</code> <a class="header-anchor" href="#integer" aria-label="Permalink to "`integer`"">β</a></h2><p>The field under validation must have an integer value.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-EXyPp" id="tab-oW4S-LE" checked="checked"><label for="tab-oW4S-LE">Declarative</label><input type="radio" name="group-EXyPp" id="tab-7Qv8j1s"><label for="tab-7Qv8j1s">Function-based</label><input type="radio" name="group-EXyPp" id="tab-dU1oko1"><label for="tab-dU1oko1">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { age: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"integer"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, integer } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { age: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isInteger } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isInteger</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">134</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>integer</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>integer</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>integer</code></td><td><code>123</code></td><td>π’</td></tr><tr><td><code>integer</code></td><td><code>3.14</code></td><td>π΄</td></tr><tr><td><code>integer</code></td><td><code>abc</code></td><td>π΄</td></tr></tbody></table><h2 id="max-value" tabindex="-1"><code>max:value</code> <a class="header-anchor" href="#max-value" aria-label="Permalink to "`max:value`"">β</a></h2><p>Validate that an attribute is no greater than a given size</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-N89Cy" id="tab-2CxbTxH" checked="checked"><label for="tab-2CxbTxH">Declarative</label><input type="radio" name="group-N89Cy" id="tab-GYkEKT5"><label for="tab-GYkEKT5">Function-based</label><input type="radio" name="group-N89Cy" id="tab-qpagemK"><label for="tab-qpagemK">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { age: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"max:99"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, max } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { age: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">max</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">99</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isMax } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isMax</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">10</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">99</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>max:5</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>max:5</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>max:5</code></td><td><code>'123'</code></td><td>π’</td></tr><tr><td><code>max:5</code></td><td><code>3</code></td><td>π’</td></tr><tr><td><code>max:5</code></td><td><code>'abcdef'</code></td><td>π΄</td></tr><tr><td><code>max:5</code></td><td><code>10</code></td><td>π΄</td></tr></tbody></table><h2 id="min-value" tabindex="-1"><code>min:value</code> <a class="header-anchor" href="#min-value" aria-label="Permalink to "`min:value`"">β</a></h2><p>Validate that an attribute is at least a given size.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-Y_l93" id="tab-9cjKmEO" checked="checked"><label for="tab-9cjKmEO">Declarative</label><input type="radio" name="group-Y_l93" id="tab-sxEOhXw"><label for="tab-sxEOhXw">Function-based</label><input type="radio" name="group-Y_l93" id="tab-JV-O6GW"><label for="tab-JV-O6GW">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { age: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"min:22"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, min } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { age: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">min</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">22</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isMin } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isMin</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">10</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">22</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>min:5</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>min:5</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>min:5</code></td><td><code>'abcdef'</code></td><td>π’</td></tr><tr><td><code>min:5</code></td><td><code>'123456'</code></td><td>π’</td></tr><tr><td><code>min:5</code></td><td><code>10</code></td><td>π’</td></tr><tr><td><code>min:5</code></td><td><code>'abcdef'</code></td><td>π΄</td></tr><tr><td><code>min:5</code></td><td><code>2</code></td><td>π΄</td></tr></tbody></table><h2 id="not-in-foo-bar" tabindex="-1"><code>not_in:foo,bar,...</code> <a class="header-anchor" href="#not-in-foo-bar" aria-label="Permalink to "`not_in:foo,bar,...`"">β</a></h2><p>The field under validation must not be included in the given list of values.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-cSRBW" id="tab-2Rk9_wp" checked="checked"><label for="tab-2Rk9_wp">Declarative</label><input type="radio" name="group-cSRBW" id="tab-ApHQkWl"><label for="tab-ApHQkWl">Function-based</label><input type="radio" name="group-cSRBW" id="tab-RViQ52d"><label for="tab-RViQ52d">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { userChoice: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"not_in:news,marketing"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, notIn } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { userChoice: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">notIn</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">([</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"news"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"marketing"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">])] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isNotIn } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isNotIn</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"your-data"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, [</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"news"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"marketing"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>not_in:A,B</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>not_in:A,B</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>not_in:A,B</code></td><td><code>C</code></td><td>π’</td></tr><tr><td><code>not_in:A,B</code></td><td><code>A</code></td><td>π΄</td></tr><tr><td><code>not_in:A,B</code></td><td><code>B</code></td><td>π΄</td></tr><tr><td><code>not_in:A,B</code></td><td><code>true</code></td><td>π΄</td></tr></tbody></table><h2 id="numeric" tabindex="-1"><code>numeric</code> <a class="header-anchor" href="#numeric" aria-label="Permalink to "`numeric`"">β</a></h2><p>Validate that an attribute is numeric.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-MFzm4" id="tab-lO2Rm-a" checked="checked"><label for="tab-lO2Rm-a">Declarative</label><input type="radio" name="group-MFzm4" id="tab-QC-Ou-B"><label for="tab-QC-Ou-B">Function-based</label><input type="radio" name="group-MFzm4" id="tab-_b-mhH9"><label for="tab-_b-mhH9">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { salary: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"numeric"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, numeric } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { salary: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">numeric</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isNumeric } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isNumeric</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">3000</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>integer</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>integer</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>integer</code></td><td><code>123</code></td><td>π’</td></tr><tr><td><code>integer</code></td><td><code>3.14</code></td><td>π’</td></tr><tr><td><code>integer</code></td><td><code>abc</code></td><td>π΄</td></tr></tbody></table><h2 id="required" tabindex="-1"><code>required</code> <a class="header-anchor" href="#required" aria-label="Permalink to "`required`"">β</a></h2><p>Checks if the value is provided.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-DogTK" id="tab-pe315ip" checked="checked"><label for="tab-pe315ip">Declarative</label><input type="radio" name="group-DogTK" id="tab-cwQ3KHI"><label for="tab-cwQ3KHI">Function-based</label><input type="radio" name="group-DogTK" id="tab-XiuieLm"><label for="tab-XiuieLm">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { salary: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"required"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, required } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { salary: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">required</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isRequired } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isRequired</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"your-data"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>required</code></td><td><code>john</code></td><td>π’</td></tr><tr><td><code>required</code></td><td><code>123</code></td><td>π’</td></tr><tr><td><code>required</code></td><td><code>1.23</code></td><td>π’</td></tr><tr><td><code>required</code></td><td><code>{}</code></td><td>π’</td></tr><tr><td><code>required</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>required</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>required</code></td><td><code>''</code></td><td>π΄</td></tr><tr><td><code>required</code></td><td><code>' '</code></td><td>π΄</td></tr></tbody></table><h2 id="size-value" tabindex="-1"><code>size:value</code> <a class="header-anchor" href="#size-value" aria-label="Permalink to "`size:value`"">β</a></h2><p>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.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-FoV0A" id="tab-f6P5HIn" checked="checked"><label for="tab-f6P5HIn">Declarative</label><input type="radio" name="group-FoV0A" id="tab-thw_FvA"><label for="tab-thw_FvA">Function-based</label><input type="radio" name="group-FoV0A" id="tab-0Cpk4KJ"><label for="tab-0Cpk4KJ">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { password: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"size:12"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, size } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { password: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">size</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">12</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isSize } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isSize</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"your-data"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">12</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>size:3</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>size:3</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>size:3</code></td><td><code>abc</code></td><td>π’</td></tr><tr><td><code>size:3</code></td><td><code>1</code></td><td>π’</td></tr><tr><td><code>size:3</code></td><td><code>1.23</code></td><td>π’</td></tr><tr><td><code>size:3</code></td><td><code>abcde</code></td><td>π΄</td></tr><tr><td><code>size:3</code></td><td><code>10</code></td><td>π΄</td></tr></tbody></table><h2 id="string" tabindex="-1"><code>string</code> <a class="header-anchor" href="#string" aria-label="Permalink to "`string`"">β</a></h2><p>The field under validation must be a string.</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-GspbV" id="tab-PJfYSTO" checked="checked"><label for="tab-PJfYSTO">Declarative</label><input type="radio" name="group-GspbV" id="tab--A2FGaI"><label for="tab--A2FGaI">Function-based</label><input type="radio" name="group-GspbV" id="tab-h68mRR6"><label for="tab-h68mRR6">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { content: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"string"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, string } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { content: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">string</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isString } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isString</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"your-data"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>string</code></td><td><code>abc</code></td><td>π’</td></tr><tr><td><code>string</code></td><td><code>''</code></td><td>π’</td></tr><tr><td><code>string</code></td><td><code>' '</code></td><td>π’</td></tr><tr><td><code>string</code></td><td><code>1</code></td><td>π΄</td></tr><tr><td><code>string</code></td><td><code>1.23</code></td><td>π΄</td></tr><tr><td><code>string</code></td><td><code>abcde</code></td><td>π΄</td></tr><tr><td><code>string</code></td><td><code>10</code></td><td>π΄</td></tr><tr><td><code>string</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>string</code></td><td><code>undefined</code></td><td>π΄</td></tr></tbody></table><h2 id="url" tabindex="-1"><code>url</code> <a class="header-anchor" href="#url" aria-label="Permalink to "`url`"">β</a></h2><p>Validate that an attribute has a valid URL format</p><div class="vp-code-group vp-adaptive-theme"><div class="tabs"><input type="radio" name="group-57xmU" id="tab-BeT36Gr" checked="checked"><label for="tab-BeT36Gr">Declarative</label><input type="radio" name="group-57xmU" id="tab-jYYPmH9"><label for="tab-jYYPmH9">Function-based</label><input type="radio" name="group-57xmU" id="tab-tU7DmUI"><label for="tab-tU7DmUI">Direct usage</label></div><div class="blocks"><div class="language-ts vp-adaptive-theme active"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { profile: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"url"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { validate, url } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">await</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> validate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data, { profile: [</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">url</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()] });</span></span></code></pre></div><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { isUrl } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">from</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> "robust-validator"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">// ...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">isUrl</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"https://axe-api-com"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div></div></div><table><thead><tr><th>Rule</th><th>Value</th><th>Is valid?</th></tr></thead><tbody><tr><td><code>url</code></td><td><code>null</code></td><td>π΄</td></tr><tr><td><code>url</code></td><td><code>undefined</code></td><td>π΄</td></tr><tr><td><code>url</code></td><td><code>https://example.com</code></td><td>π’</td></tr><tr><td><code>url</code></td><td><code>http://example.com</code></td><td>π’</td></tr><tr><td><code>url</code></td><td><code>ftp://example.com</code></td><td>π’</td></tr><tr><td><code>url</code></td><td><code>invalid-url</code></td><td>π΄</td></tr></tbody></table></div></div></main><footer class="VPDocFooter" data-v-a3c25e27 data-v-b4b63abf><!--[--><!--]--><div class="edit-info" data-v-b4b63abf><div class="edit-link" data-v-b4b63abf><a class="VPLink link vp-external-link-icon no-icon edit-link-button" href="https://github.com/axe-api/validator/edit/main/docs/rules.md" target="_blank" rel="noreferrer" data-v-b4b63abf><!--[--><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="edit-link-icon" aria-label="edit icon" data-v-b4b63abf><path d="M18,23H4c-1.7,0-3-1.3-3-3V6c0-1.7,1.3-3,3-3h7c0.6,0,1,0.4,1,1s-0.4,1-1,1H4C3.4,5,3,5.4,3,6v14c0,0.6,0.4,1,1,1h14c0.6,0,1-0.4,1-1v-7c0-0.6,0.4-1,1-1s1,0.4,1,1v7C21,21.7,19.7,23,18,23z"></path><path d="M8,17c-0.3,0-0.5-0.1-0.7-0.3C7,16.5,6.9,16.1,7,15.8l1-4c0-0.2,0.1-0.3,0.3-0.5l9.5-9.5c1.2-1.2,3.2-1.2,4.4,0c1.2,1.2,1.2,3.2,0,4.4l-9.5,9.5c-0.1,0.1-0.3,0.2-0.5,0.3l-4,1C8.2,17,8.1,17,8,17zM9.9,12.5l-0.5,2.1l2.1-0.5l9.3-9.3c0.4-0.4,0.4-1.1,0-1.6c-0.4-0.4-1.2-0.4-1.6,0l0,0L9.9,12.5z M18.5,2.5L18.5,2.5L18.5,2.5z"></path></svg> Edit this page on GitHub<!--]--></a></div><!----></div><nav class="prev-next" data-v-b4b63abf><div class="pager" data-v-b4b63abf><a class="VPLink link pager-link prev" href="/terminology.html" data-v-b4b63abf><!--[--><span class="desc" data-v-b4b63abf>Previous page</span><span class="title" data-v-b4b63abf>Terminology</span><!--]--></a></div><div class="pager" data-v-b4b63abf><a class="VPLink link pager-link next" href="/i18n.html" data-v-b4b63abf><!--[--><span class="desc" data-v-b4b63abf>Next page</span><span class="title" data-v-b4b63abf>i18n</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><footer class="VPFooter has-sidebar" data-v-9d8abc1e data-v-566314d4><div class="container" data-v-566314d4><p class="message" data-v-566314d4>Released under the MIT License.</p><p class="copyright" data-v-566314d4>Copyright Β© 2020-present</p></div></footer><!--[--><!--]--></div></div>
<script>window.__VP_HASH_MAP__=JSON.parse("{\"api-examples.md\":\"aC7nU3mz\",\"customization.md\":\"CRjWkGJX\",\"examples.md\":\"DDel7tVM\",\"getting-started.md\":\"BQpJF-s-\",\"i18n.md\":\"BM2fmndZ\",\"index.md\":\"BlM-mARF\",\"options.md\":\"DCzrT-MG\",\"rules.md\":\"BNE2Opk6\",\"terminology.md\":\"CviqoI6F\",\"why.md\":\"D0tDhscL\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"Robust Validator\",\"description\":\"Another data validation library\",\"base\":\"/\",\"head\":[],\"router\":{\"prefetchLinks\":true},\"appearance\":true,\"themeConfig\":{\"nav\":[{\"text\":\"Demo\",\"link\":\"https://validator.axe-api.com/demo\"}],\"editLink\":{\"pattern\":\"https://github.com/axe-api/validator/edit/main/docs/:path\",\"text\":\"Edit this page on GitHub\"},\"sidebar\":[{\"text\":\"Introduction\",\"items\":[{\"text\":\"Why?\",\"link\":\"/why\"},{\"text\":\"Getting started\",\"link\":\"/getting-started\"},{\"text\":\"Examples\",\"link\":\"/examples\"},{\"text\":\"Terminology\",\"link\":\"/terminology\"}]},{\"text\":\"Reference\",\"items\":[{\"text\":\"Rules\",\"link\":\"/rules\"},{\"text\":\"i18n\",\"link\":\"/i18n\"},{\"text\":\"Customization\",\"link\":\"/customization\"},{\"text\":\"Options\",\"link\":\"/options\"}]}],\"socialLinks\":[{\"icon\":\"github\",\"link\":\"https://github.com/axe-api/validator\"}],\"footer\":{\"message\":\"Released under the MIT License.\",\"copyright\":\"Copyright Β© 2020-present\"},\"search\":{\"provider\":\"local\"}},\"locales\":{},\"scrollOffset\":90,\"cleanUrls\":false}");</script>
</body>
</html>