@@ -30,12 +30,12 @@ php artisan vendor:publish --provider="Arifszn\AdvancedValidation\ServiceProvide
3030You can specify the error message on the fly when declaring the rules. Simple pass the error message parameter.
3131
3232``` php
33- use Arifszn\AdvancedValidation\Rules\Base64Image ;
33+ use Arifszn\AdvancedValidation\Rules\Username ;
3434
3535public function rules()
3636{
3737 return [
38- 'avatar ' => [new Base64Image ('Your custom error message')],
38+ 'foo ' => [new Username ('Your custom error message')],
3939 ];
4040}
4141```
@@ -52,15 +52,23 @@ public function rules()
5252- [ ` Divisible By ` ] ( #divisibleby )
5353- [ ` Ethereum Address ` ] ( #ethereumaddress )
5454- [ ` Float Number ` ] ( #floatnumber )
55+ - [ ` Hash ` ] ( #hash )
5556- [ ` Image URL ` ] ( #imageurl )
57+ - [ ` JWT ` ] ( #jwt )
58+ - [ ` Name ` ] ( #name )
5659- [ ` Phone ` ] ( #phone )
60+ - [ ` Username ` ] ( #username )
5761- [ ` Without Spaces ` ] ( #withoutspaces )
5862
5963
6064### ` Ascii `
6165
6266The field under validation must contain ASCII chars only.
6367
68+ ```
69+ public Arifszn\AdvancedValidation\Rules\Ascii::__construct(string $errorMessage = null)
70+ ```
71+
6472``` php
6573use Arifszn\AdvancedValidation\Rules\Ascii;
6674
@@ -76,6 +84,10 @@ public function rules()
7684
7785The field under validation must be a Base64 encoded image.
7886
87+ ```
88+ public Arifszn\AdvancedValidation\Rules\Base64Image::__construct(string $errorMessage = null)
89+ ```
90+
7991``` php
8092use Arifszn\AdvancedValidation\Rules\Base64Image;
8193
@@ -91,6 +103,10 @@ public function rules()
91103
92104The field under validation must be a Base64 encoded string.
93105
106+ ```
107+ public Arifszn\AdvancedValidation\Rules\Base64String::__construct(string $errorMessage = null)
108+ ```
109+
94110``` php
95111use Arifszn\AdvancedValidation\Rules\Base64String;
96112
@@ -106,6 +122,10 @@ public function rules()
106122
107123The field under validation must be a BIC([ Business Identifier Code] ( https://en.wikipedia.org/wiki/ISO_9362 ) ) or SWIFT code.
108124
125+ ```
126+ public Arifszn\AdvancedValidation\Rules\BIC::__construct(string $errorMessage = null)
127+ ```
128+
109129``` php
110130use Arifszn\AdvancedValidation\Rules\BIC;
111131
@@ -121,6 +141,10 @@ public function rules()
121141
122142The field under validation must be a valid BTC address.
123143
144+ ```
145+ public Arifszn\AdvancedValidation\Rules\BtcAddress::__construct(string $errorMessage = null)
146+ ```
147+
124148``` php
125149use Arifszn\AdvancedValidation\Rules\BtcAddress;
126150
@@ -136,6 +160,10 @@ public function rules()
136160
137161The field under validation must be a valid credit card number.
138162
163+ ```
164+ public Arifszn\AdvancedValidation\Rules\CreditCard::__construct(string $errorMessage = null)
165+ ```
166+
139167``` php
140168use Arifszn\AdvancedValidation\Rules\CreditCard;
141169
@@ -151,6 +179,10 @@ public function rules()
151179
152180The field under validation must have [ data uri format] ( https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs ) .
153181
182+ ```
183+ public Arifszn\AdvancedValidation\Rules\DataURI::__construct(string $errorMessage = null)
184+ ```
185+
154186``` php
155187use Arifszn\AdvancedValidation\Rules\DataURI;
156188
@@ -166,6 +198,10 @@ public function rules()
166198
167199The field under validation must be divisible by the given number.
168200
201+ ```
202+ public Arifszn\AdvancedValidation\Rules\DivisibleBy::__construct(int $number, string $errorMessage = null)
203+ ```
204+
169205``` php
170206use Arifszn\AdvancedValidation\Rules\DivisibleBy;
171207
@@ -180,6 +216,10 @@ public function rules()
180216### ` EthereumAddress `
181217The field under validation must be an [ Ethereum] ( https://ethereum.org/en/ ) address. Does not validate address checksums.
182218
219+ ```
220+ public Arifszn\AdvancedValidation\Rules\EthereumAddress::__construct(string $errorMessage = null)
221+ ```
222+
183223``` php
184224use Arifszn\AdvancedValidation\Rules\EthereumAddress;
185225
@@ -195,6 +235,10 @@ public function rules()
195235
196236The field under validation must be a float number.
197237
238+ ```
239+ public Arifszn\AdvancedValidation\Rules\FloatNumber::__construct(string $errorMessage = null)
240+ ```
241+
198242``` php
199243use Arifszn\AdvancedValidation\Rules\FloatNumber;
200244
@@ -206,13 +250,38 @@ public function rules()
206250}
207251```
208252
253+ ### ` Hash `
254+
255+ The field under validation must be a hash of type algorithm.
256+
257+ Algorithm is one of ` 'md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b' ` .
258+
259+ ```
260+ public Arifszn\AdvancedValidation\Rules\Hash::__construct(string $algorithm, string $errorMessage = null)
261+ ```
262+
263+ ``` php
264+ use Arifszn\AdvancedValidation\Rules\Hash;
265+
266+ public function rules()
267+ {
268+ return [
269+ 'foo' => [new Hash('md4')],
270+ ];
271+ }
272+ ```
273+
209274### ` ImageURL `
210275
211276The field under validation must be a valid image URL.
212277
213278✓ https://www.php.net/images/logos/php-logo.png \
214279✕ https://imaginarysite123.com/invalid.png
215280
281+ ```
282+ public Arifszn\AdvancedValidation\Rules\ImageURL::__construct(string $errorMessage = null)
283+ ```
284+
216285``` php
217286use Arifszn\AdvancedValidation\Rules\ImageURL;
218287
@@ -224,6 +293,48 @@ public function rules()
224293}
225294```
226295
296+ ### ` JWT `
297+
298+ The field under validation must have a valid format of JWT ([ JSON Web Token] ( https://en.wikipedia.org/wiki/JSON_Web_Token ) ).
299+
300+ ```
301+ public Arifszn\AdvancedValidation\Rules\Jwt::__construct(string $errorMessage = null)
302+ ```
303+
304+ ``` php
305+ use Arifszn\AdvancedValidation\Rules\Jwt;
306+
307+ public function rules()
308+ {
309+ return [
310+ 'foo' => [new Jwt()],
311+ ];
312+ }
313+ ```
314+
315+ ### ` Name `
316+
317+ The field under validation must be a valid name.
318+
319+ - no emoji
320+ - no number (if $allowNumber flag is true, it will accept numbers, default is false)
321+ - special characters are allowed (restricting special characters will cause false-negative for names like ` Martin Luther King, Jr. ` or ` 李小龍 ` )
322+
323+ ```
324+ public Arifszn\AdvancedValidation\Rules\Name::__construct(bool $allowNumber = false, string $errorMessage = null)
325+ ```
326+
327+ ``` php
328+ use Arifszn\AdvancedValidation\Rules\Name;
329+
330+ public function rules()
331+ {
332+ return [
333+ 'name' => [new Name()],
334+ ];
335+ }
336+ ```
337+
227338### ` Phone `
228339
229340The field under validation must be a valid phone number.
@@ -233,6 +344,10 @@ The field under validation must be a valid phone number.
233344✓ (xxx) xxx-xxxx \
234345✓ xxxxxxxxxx
235346
347+ ```
348+ public Arifszn\AdvancedValidation\Rules\Phone::__construct(string $errorMessage = null)
349+ ```
350+
236351``` php
237352use Arifszn\AdvancedValidation\Rules\Phone;
238353
@@ -244,10 +359,38 @@ public function rules()
244359}
245360```
246361
362+ ### ` Username `
363+
364+ The field under validation must be a valid username.
365+
366+ - starts with a letter (alpha)
367+ - only alpha-numeric (a-z, A-Z, 0-9), underscore, minus and dot
368+ - multiple underscores, minus and are not allowed (-- or __ or ..)
369+ - underscores, minus and dot are not allowed at the beginning or end
370+
371+ ```
372+ public Arifszn\AdvancedValidation\Rules\Username::__construct(string $errorMessage = null)
373+ ```
374+
375+ ``` php
376+ use Arifszn\AdvancedValidation\Rules\Username;
377+
378+ public function rules()
379+ {
380+ return [
381+ 'username' => [new Username()],
382+ ];
383+ }
384+ ```
385+
247386### ` WithoutSpaces `
248387
249388The field under validation must not contain spaces.
250389
390+ ```
391+ public Arifszn\AdvancedValidation\Rules\WithoutSpaces::__construct(string $errorMessage = null)
392+ ```
393+
251394``` php
252395use Arifszn\AdvancedValidation\Rules\WithoutSpaces;
253396
0 commit comments