Skip to content

Commit bc63120

Browse files
Refactoring and added placeholder support
New syntax [The :name field is required]
1 parent 74a21e4 commit bc63120

File tree

8 files changed

+81
-40
lines changed

8 files changed

+81
-40
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to `shergela/validation-rule` will be documented in this file.
44

5+
## 1.0.7 | 12 September - 2024
6+
- Refactoring code.
7+
- Added support for substitutions in messages, This is needed to be able to write good messages.
8+
Placeholder will allow you to write messages using positioning.
9+
- New syntax for messages "The :name field is required.", or "The :email field is required."
10+
11+
512
## 1.0.6 | 06 September - 2024
613

714
- add new `uppercaseWord()` method.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Build custom laravel validation rules easily
22

3+
> This package is under development, please do not use in production.
4+
> You can download and test it.
5+
36
## Installation
47
Require the package with composer using the following command:
58

src/Constants/ValidationRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ class ValidationRule
4444
/**
4545
* The field under validation must be included in the given list of values in:foo,bar...
4646
*/
47-
public const IN = 'in:';
47+
public const IN = 'in';
4848

4949
/**
5050
* The field under validation must not be included in the given list of values not_in:foo,bar,bar...
5151
*/
52-
public const NOT_IN = 'not_in:';
52+
public const NOT_IN = 'not_in';
5353
}

src/Rules/SeparateIntegersByComma.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Closure;
66
use Illuminate\Contracts\Validation\ValidationRule;
7-
use Illuminate\Support\Str;
87
use Shergela\Validations\Constants\ValidationRegex as Regex;
98

109
class SeparateIntegersByComma implements ValidationRule

src/Rules/SeparateStringsByComma.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Closure;
66
use Illuminate\Contracts\Validation\ValidationRule;
7-
use Illuminate\Support\Str;
87
use Shergela\Validations\Constants\ValidationRegex as Regex;
98

109
class SeparateStringsByComma implements ValidationRule

src/Rules/SeparateStringsByUnderscore.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Closure;
66
use Illuminate\Contracts\Validation\ValidationRule;
7-
use Illuminate\Support\Str;
87
use Shergela\Validations\Constants\ValidationRegex as Regex;
98

109
class SeparateStringsByUnderscore implements ValidationRule

src/Validation/BuildValidationRule.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ class BuildValidationRule
339339
/**
340340
* @var bool
341341
*/
342-
protected ?bool $distinctStinct = false;
342+
protected ?bool $distinctStrict = false;
343343

344344
/**
345345
* @var bool
@@ -468,8 +468,10 @@ protected function buildValidationRules(): array
468468
? [DateRule::DATE_BEFORE_OR_EQUAL . $this->dateBeforeOrEqual]
469469
: []
470470
),
471+
471472
...($this->dateAfterOrEqualToday === true ? [DateRule::DATE_AFTER_OR_EQUAL_TODAY] : []),
472473
...($this->dateAfter !== null ? [DateRule::DATE_AFTER . $this->dateAfter] : []),
474+
473475
...($this->dateAfterOrEqual !== null
474476
? [DateRule::DATE_AFTER_OR_EQUAL . $this->dateAfterOrEqual]
475477
: []
@@ -507,7 +509,7 @@ protected function buildValidationRules(): array
507509
*/
508510
...($this->array === true ? [ArrayRule::ARRAY] : []),
509511
...($this->arrayDistinct === true ? [ArrayRule::DISTINCT] : []),
510-
...($this->distinctStinct === true ? [ArrayRule::DISTINCT_STRICT] : []),
512+
...($this->distinctStrict === true ? [ArrayRule::DISTINCT_STRICT] : []),
511513
...($this->distinctIgnoreCase === true ? [ArrayRule::DISTINCT_IGNORE_CASE] : []),
512514
];
513515

0 commit comments

Comments
 (0)