Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Strict Validation Rules greater_than/less_than #6492

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions system/Validation/StrictRules/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,36 @@ public function exact_length($str, string $val): bool
/**
* Greater than
*
* @param mixed $str
* @param mixed $str expects int|string
*/
public function greater_than($str, string $min): bool
{
if (is_int($str)) {
$str = (string) $str;
}
MGatner marked this conversation as resolved.
Show resolved Hide resolved

if (! is_string($str)) {
return false;
}

return $this->nonStrictRules->greater_than($str, $min);
}

/**
* Equal to or Greater than
*
* @param mixed $str
* @param mixed $str expects int|string
*/
public function greater_than_equal_to($str, string $min): bool
{
if (is_int($str)) {
$str = (string) $str;
}

if (! is_string($str)) {
return false;
}

return $this->nonStrictRules->greater_than_equal_to($str, $min);
}

Expand Down Expand Up @@ -141,20 +157,36 @@ public function is_unique($str, string $field, array $data): bool
/**
* Less than
*
* @param mixed $str
* @param mixed $str expects int|string
*/
public function less_than($str, string $max): bool
{
if (is_int($str)) {
$str = (string) $str;
}

if (! is_string($str)) {
return false;
}

return $this->nonStrictRules->less_than($str, $max);
}

/**
* Equal to or Less than
*
* @param mixed $str
* @param mixed $str expects int|string
*/
public function less_than_equal_to($str, string $max): bool
{
if (is_int($str)) {
$str = (string) $str;
}

if (! is_string($str)) {
return false;
}

return $this->nonStrictRules->less_than_equal_to($str, $max);
}

Expand Down
8 changes: 5 additions & 3 deletions tests/system/Validation/RulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@

/**
* @internal
*
* @no-final
*/
final class RulesTest extends CIUnitTestCase
class RulesTest extends CIUnitTestCase
{
private Validation $validation;
private array $config = [
protected Validation $validation;
protected array $config = [
'ruleSets' => [
Rules::class,
FormatRules::class,
Expand Down
Loading