Skip to content

Commit 507fe4a

Browse files
authored
Merge pull request #20 from vdhicts/feature/deprecate-builtin-rules
Deprecate rules that are already available in Laravel
2 parents d84f508 + f17b000 commit 507fe4a

File tree

4 files changed

+63
-22
lines changed

4 files changed

+63
-22
lines changed

README.md

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ The package includes both English and Dutch translations. The translations can b
3434

3535
Validates the provided [BIC number](https://www.betaalvereniging.nl/en/focus/giro-based-and-online-payments/bank-identifier-code-bic-for-sepa-transactions/).
3636

37+
```php
38+
'field' => [new \BicNumber()],
39+
```
40+
3741
### Contains
3842

3943
Validates if the value contains a certain phrase.
@@ -77,26 +81,50 @@ When the date is not according to the 'Y-m-d H:i' format then you are able to sp
7781
Validates if the value is a valid dutch phone number. Both mobile or landlines are supported. See the `Phone` validation
7882
rule to validate a phone number which isn't limited to the Netherlands.
7983

84+
```php
85+
'field' => [new DutchPhone()],
86+
```
87+
8088
### DutchPostalCode
8189

8290
Validates if the value is a valid dutch zip code, like `1234AB`.
8391

92+
```php
93+
'field' => [new DutchPostalCode()],
94+
```
95+
8496
### HexColor
8597

8698
Validates if the value contains a hex color, like `#000000`.
8799

100+
```php
101+
'field' => [new HexColor()],
102+
```
103+
88104
### HostName
89105

90106
Validates if the value contains a valid hostname, like `example.com`.
91107

108+
```php
109+
'field' => [new HostName()],
110+
```
111+
92112
### InternationalBankAccountNumber
93113

94114
Validates if the value contains a valid [IBAN](https://en.wikipedia.org/wiki/International_Bank_Account_Number).
95115

116+
```php
117+
'field' => [new InternationalBankAccountNumber()],
118+
```
119+
96120
### Interval
97121

98122
Validates if the value is an interval, i.e. `PT30S`.
99123

124+
```php
125+
'field' => [new Interval()],
126+
```
127+
100128
### MaximumHourDifference
101129

102130
Validates if the value is differing less then the provided amount of hours.
@@ -107,7 +135,11 @@ Validates if the value is differing less then the provided amount of hours.
107135

108136
### Mime Type
109137

110-
Validates if the value is valid MIME.
138+
Validates if the value is a structural valid MIME.
139+
140+
```php
141+
'field' => [new MimeType()],
142+
```
111143

112144
### NotContains
113145

@@ -117,34 +149,22 @@ Validates if the value *NOT* contains a certain phrase.
117149
'field' => [new NotContains($needle)],
118150
```
119151

120-
### NotEndsWith
152+
### Phone
121153

122-
Validates if the value *NOT* ends with a certain phrase.
154+
Validates if the value is a valid phone number.
123155

124156
```php
125-
'field' => [new NotEndsWith($needle)],
157+
'field' => [new Phone()],
126158
```
127159

128-
### NotStartsWith
160+
### Positive interval
129161

130-
Validates if the value *NOT* starts with a certain phrase.
162+
Validates if the value is an interval and the interval is positive.
131163

132164
```php
133-
'field' => [new NotStartsWith($needle)],
165+
'field' => [new PositiveInterval()],
134166
```
135167

136-
### Password strength
137-
138-
Validates if the value contains at least a letter, a capital and a number.
139-
140-
### Phone
141-
142-
Validates if the value is a valid phone number.
143-
144-
### Positive interval
145-
146-
Validates if the value is an interval and the interval is positive.
147-
148168
### Price
149169

150170
Validates if the value is a valid price. The rule optionally accepts a specific decimal sign. When the decimal isn't
@@ -159,21 +179,33 @@ provided it accepts both `,` or `.` signs.
159179

160180
Validates if the value is a valid secure url, i.e. is a HTTPS url.
161181

182+
```php
183+
'field' => [new SecureUrl()],
184+
```
185+
162186
### Semver
163187

164188
Validates if the value is a valid version according to the [Semver](https://semver.org/) standard.
165189

190+
```php
191+
'field' => [new Semver()],
192+
```
193+
166194
### VatNumber
167195

168196
Validates if the value is a valid formatted VAT number.
169197

198+
```php
199+
'field' => [new VatNumber()],
200+
```
201+
170202
**Be aware**: It doesn't check if the number is known in the VAT database. If you need to know the VAT number is truly
171-
legit, I'm currently offering an easy to use (paid) service for that.
203+
legit, check with [VIES](https://ec.europa.eu/taxation_customs/vies/#/vat-validation).
172204

173205
## Contribution
174206

175-
Any contribution is welcome, but it should be (unit) tested and meet the PSR-2 standard and please create one pull
176-
request per feature. In exchange you will be credited as contributor on this page.
207+
Any contribution is welcome, but it should be (unit) tested and meet the PSR-12 standard and please create one pull
208+
request per feature. In exchange, you will be credited as contributor on this page.
177209

178210
## Security
179211

src/Rules/NotEndsWith.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
use Illuminate\Contracts\Validation\Rule;
66
use Illuminate\Support\Str;
77

8+
/**
9+
* @deprecated use the builtin `doesnt_end_with`
10+
*/
811
class NotEndsWith implements Rule
912
{
1013
private string $needle;

src/Rules/NotStartsWith.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
use Illuminate\Contracts\Validation\Rule;
66
use Illuminate\Support\Str;
77

8+
/**
9+
* @deprecated use the builtin `doesnt_start_with`
10+
*/
811
class NotStartsWith implements Rule
912
{
1013
private string $needle;

src/Rules/PasswordStrength.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
use Illuminate\Contracts\Validation\Rule;
66
use Illuminate\Support\Str;
77

8+
/**
9+
* @deprecated use the builtin `Password`. A drop in replacement: `Password::min(8)->mixedCase()->numbers()`
10+
*/
811
final class PasswordStrength implements Rule
912
{
1013
/**

0 commit comments

Comments
 (0)