12
12
use Shergela \Validations \Rules \SeparateIntegersByComma as IntegerByComma ;
13
13
use Shergela \Validations \Rules \SeparateStringsByComma as StringByComma ;
14
14
use Shergela \Validations \Rules \SeparateStringsByUnderscore as StringByUnderscore ;
15
+ use Shergela \Validations \Enums \ValidationArrayEnum as ArrayEnum ;
15
16
use Shergela \Validations \Rules \TimezoneRegionValidation ;
16
17
use Shergela \Validations \Rules \TimezoneValidation ;
17
18
use Shergela \Validations \Rules \UppercaseFirstLetter ;
@@ -37,7 +38,7 @@ class BuildValidationRule
37
38
* @var string|null
38
39
* Set custom message
39
40
*/
40
- protected static ?string $ customMessage = null ;
41
+ protected static ?string $ validationMessage = null ;
41
42
42
43
/**
43
44
* @var int|null
@@ -317,6 +318,26 @@ class BuildValidationRule
317
318
*/
318
319
protected static ?string $ notIn = null ;
319
320
321
+ /**
322
+ * @var bool
323
+ */
324
+ protected bool $ array = false ;
325
+
326
+ /**
327
+ * @var bool
328
+ */
329
+ protected bool $ arrayDistinct = false ;
330
+
331
+ /**
332
+ * @var bool
333
+ */
334
+ protected ?bool $ distinctStinct = false ;
335
+
336
+ /**
337
+ * @var bool
338
+ */
339
+ protected bool $ distinctIgnoreCase = false ;
340
+
320
341
/**
321
342
* @return array<string>
322
343
*/
@@ -384,13 +405,13 @@ protected function buildValidationRules(): array
384
405
385
406
...(
386
407
$ this ->uppercaseFirstLetter === true
387
- ? [new UppercaseFirstLetter (message: static ::$ customMessage )]
408
+ ? [new UppercaseFirstLetter (message: static ::$ validationMessage )]
388
409
: []
389
410
),
390
411
391
412
...(
392
413
$ this ->lowercaseFirstLetter === true
393
- ? [new LowercaseFirstLetter (message: static ::$ customMessage )]
414
+ ? [new LowercaseFirstLetter (message: static ::$ validationMessage )]
394
415
: []
395
416
),
396
417
@@ -407,7 +428,7 @@ protected function buildValidationRules(): array
407
428
408
429
...(
409
430
$ this ->timezones !== null
410
- ? [new TimezoneValidation (timezones: $ this ->timezones , message: static ::$ customMessage )]
431
+ ? [new TimezoneValidation (timezones: $ this ->timezones , message: static ::$ validationMessage )]
411
432
: []
412
433
),
413
434
@@ -418,7 +439,7 @@ protected function buildValidationRules(): array
418
439
cities: $ this ->timezoneIdentifierCities ,
419
440
timezoneGroupNumber: $ this ->dateTimezoneGroupNumber ,
420
441
timezoneGroup: $ this ->dateTimezoneGroupName ,
421
- customMessage: static ::$ customMessage ,
442
+ customMessage: static ::$ validationMessage ,
422
443
)
423
444
]
424
445
: []
@@ -439,14 +460,22 @@ protected function buildValidationRules(): array
439
460
* Regex validations
440
461
*/
441
462
...($ this ->regexPattern !== null ? [RegexRule::RULE . $ this ->regexPattern ] : []),
442
- ...($ this ->separateIntegersByComma === true ? [new IntegerByComma (message: static ::$ customMessage )] : []),
443
- ...($ this ->separateStringsByComma === true ? [new StringByComma (message: static ::$ customMessage )] : []),
463
+ ...($ this ->separateIntegersByComma === true ? [new IntegerByComma (message: static ::$ validationMessage )] : []),
464
+ ...($ this ->separateStringsByComma === true ? [new StringByComma (message: static ::$ validationMessage )] : []),
444
465
445
466
...(
446
467
$ this ->separateStringsByUnderscore === true
447
- ? [new StringByUnderscore (message: static ::$ customMessage )]
468
+ ? [new StringByUnderscore (message: static ::$ validationMessage )]
448
469
: []
449
470
),
471
+
472
+ /**
473
+ * Array validations
474
+ */
475
+ ...($ this ->array === true ? [ArrayEnum::ARRAY ] : []),
476
+ ...($ this ->arrayDistinct === true ? [ArrayEnum::DISTINCT ] : []),
477
+ ...($ this ->distinctStinct === true ? [ArrayEnum::DISTINCT_STRICT ] : []),
478
+ ...($ this ->distinctIgnoreCase === true ? [ArrayEnum::DISTINCT_IGNORE_CASE ] : []),
450
479
];
451
480
452
481
return $ rules ;
0 commit comments