Skip to content

Commit

Permalink
Change boolean position in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
filisko committed Mar 8, 2020
1 parent b37ae53 commit ce371c2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ $is_valid = GUMP::is_valid(array_merge($_POST, $_FILES), [

| Rule | Description |
|--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **boolean**,strict | Determine if the provided value is a valid boolean. Returns true for: yes/no, on/off, 1/0, true/false. In strict mode (optional) only true/false will be valid which you can combine with boolean filter. |
| **required** | Ensures the specified key value exists and is not empty. |
| **contains**,one;two;use array format if one of the values contains semicolons | Verify that a value is contained within the pre-defined value set. |
| **contains_list**,value1;value2 | Verify that a value is contained within the pre-defined value set. Error message will NOT show the list of possible values. |
| **doesnt_contain_list**,value1;value2 | Verify that a value is contained within the pre-defined value set. Error message will NOT show the list of possible values. |
| **boolean**,strict | Determine if the provided value is a valid boolean. Returns true for: yes/no, on/off, 1/0, true/false. In strict mode (optional) only true/false will be valid which you can combine with boolean filter. |
| **valid_email** | Determine if the provided email has valid format. |
| **max_len**,240 | Determine if the provided value length is less or equal to a specific value. |
| **min_len**,4 | Determine if the provided value length is more or equal to a specific value. |
Expand Down
54 changes: 27 additions & 27 deletions gump.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -915,33 +915,6 @@ protected function filter_sanitize_string($value, $params = null)
return filter_var($value, FILTER_SANITIZE_STRING);
}

/**
* Determine if the provided value is a valid boolean. Returns true for: yes/no, on/off, 1/0, true/false. In strict mode (optional) only true/false will be valid which you can combine with boolean filter.
*
* @example_parameter strict
*
* @param string $field
* @param array $input
* @param string $param
* @return bool
*/
protected function validate_boolean($field, array $input, string $param = null)
{
if ($param === 'strict') {
return in_array($input[$field], [true, false], true);
}

$booleans = [];
foreach (self::$trues as $true) {
$booleans[] = $true;
}
foreach (self::$falses as $false) {
$booleans[] = $false;
}

return in_array($input[$field], $booleans, true);
}

/**
* Converts ['1', 1, 'true', true, 'yes', 'on'] to true, anything else is false ('on' is specially useful for form checkboxes).
*
Expand Down Expand Up @@ -1154,6 +1127,33 @@ protected function validate_doesnt_contain_list($field, $input, array $param)
return !in_array($value, $param);
}

/**
* Determine if the provided value is a valid boolean. Returns true for: yes/no, on/off, 1/0, true/false. In strict mode (optional) only true/false will be valid which you can combine with boolean filter.
*
* @example_parameter strict
*
* @param string $field
* @param array $input
* @param string $param
* @return bool
*/
protected function validate_boolean($field, array $input, string $param = null)
{
if ($param === 'strict') {
return in_array($input[$field], [true, false], true);
}

$booleans = [];
foreach (self::$trues as $true) {
$booleans[] = $true;
}
foreach (self::$falses as $false) {
$booleans[] = $false;
}

return in_array($input[$field], $booleans, true);
}

/**
* Determine if the provided email has valid format.
*
Expand Down

0 comments on commit ce371c2

Please sign in to comment.