Skip to content

Commit

Permalink
change for (or/and) comparison operator only
Browse files Browse the repository at this point in the history
  • Loading branch information
tamedevelopers committed Jul 4, 2024
1 parent d56cdce commit 0882837
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ $form->rules([
| >= | Greater than or Equal to |
| < | Less than |
| <= | Less than or Equal to |
| <||> | Less than or Greater than |
| <&&> | Less than and Greater than |
| <or> | Less than or Greater than |
| <and>| Less than and Greater than |


### noInterface
Expand Down
16 changes: 8 additions & 8 deletions src/Methods/Operator.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,36 +134,36 @@ public static function validate($validator, $dataType = [])
}

//less than or greather than to operator
elseif($operator == '<||>')
elseif($operator == '<or>')
{
$dataString = $param[$input_name];
// if str_len | sl
if(in_array($dataType['data_type'], ['str_len', 'sl'])){
$dataString = strlen($dataString);
if($dataString < (float) $value || $dataString > (float) $value){
if($dataString < (int) $value || $dataString > (int) $value){
self::setOperator($operatorError);
}
}else{
$dataString = (float) $dataString;
if($dataString < (float) $value || $dataString > (float) $value){
$dataString = (int) $dataString;
if($dataString < (int) $value || $dataString > (int) $value){
self::setOperator($operatorError);
}
}
}

//less than and greather than to operator
elseif($operator == '<&&>')
elseif($operator == '<and>')
{
$dataString = $param[$input_name];
// if str_len | sl
if(in_array($dataType['data_type'], ['str_len', 'sl'])){
$dataString = strlen($dataString);
if($dataString < (float) $value && $dataString > (float) $value){
if($dataString < (int) $value && $dataString > (int) $value){
self::setOperator($operatorError);
}
}else{
$dataString = (float) $dataString;
if($dataString < (float) $value && $dataString > (float) $value){
$dataString = (int) $dataString;
if($dataString < (int) $value && $dataString > (int) $value){
self::setOperator($operatorError);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function __construct($attribute = null)
*
* - Data Types [<int/i/integer>|<float/f>|<email/e>|<url/u/link>|<array/a>|<bool/b>|<enum/en/enm>|<string/s>]
*
* - Operators [==,===,!=,!==,>,>=,<,<=,<||>,<&&>]
* - Operators [==,===,!=,!==,>,>=,<,<=,<or>,<and>]
*
* - example["string:first_name" => "First name is required"]
*
Expand Down

0 comments on commit 0882837

Please sign in to comment.