Skip to content

Commit

Permalink
Add new Laravel Rules
Browse files Browse the repository at this point in the history
  • Loading branch information
bradietilley authored May 20, 2024
2 parents 93e635d + 7dbba0b commit 7d99801
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
"illuminate/container": "^10.0|^11.0"
},
"require-dev": {
"symfony/var-dumper": "^6.1.5",
"symfony/var-dumper": "^6.1.5|^7.0",
"laravel/pint": "^1.10",
"pestphp/pest": "^2.0",
"phpstan/phpstan": "^1.8",
"orchestra/testbench": "^8.5"
"orchestra/testbench": "^8.5|^9.0"
},
"scripts": {
"lint": "pint --ansi",
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ parameters:
paths:
- src/

reportUnmatchedIgnoredErrors: true
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
- '#but does not specify its types:#'
34 changes: 34 additions & 0 deletions src/Concerns/CoreRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ public function confirmed(): static
return $this->rule('confirmed');
}

/**
* @link https://laravel.com/docs/master/validation#rule-contains
*/
public function contains(mixed ...$values): static
{
return $this->rule('contains'.self::arguments($values));
}

/**
* @link https://laravel.com/docs/master/validation#rule-current-password
*/
Expand Down Expand Up @@ -329,6 +337,8 @@ public function endsWith(string ...$prefixes): static
}

/**
* @param class-string|Enum $enum
*
* @link https://laravel.com/docs/master/validation#rule-enum
*/
public function enum(string|Enum $enum): static
Expand Down Expand Up @@ -552,6 +562,14 @@ public function lowercase(): static
return $this->rule('lowercase');
}

/**
* @link https://laravel.com/docs/master/validation#rule-list
*/
public function list(): static
{
return $this->rule('list');
}

/**
* @link https://laravel.com/docs/master/validation#rule-mac-address
*/
Expand Down Expand Up @@ -840,6 +858,22 @@ public function requiredIf(
return $this->rule('required_if'.self::arguments($fieldsAndValues));
}

/**
* @link https://laravel.com/docs/master/validation#rule-required-if-accepted
*/
public function requiredIfAccepted(string ...$fields): static
{
return $this->rule('required_if_accepted'.self::arguments($fields));
}

/**
* @link https://laravel.com/docs/master/validation#rule-required-if-declined
*/
public function requiredIfDeclined(string ...$fields): static
{
return $this->rule('required_if_declined'.self::arguments($fields));
}

/**
* @link https://laravel.com/docs/master/validation#rule-required-unless
*/
Expand Down

0 comments on commit 7d99801

Please sign in to comment.