chg: [internal] Simplified link and boolean validation

pull/7895/head
Jakub Onderka 2021-10-28 17:17:19 +02:00
parent 2f99629679
commit a1d21ecb73
1 changed files with 5 additions and 5 deletions

View File

@ -184,10 +184,10 @@ class AttributeValidationTool
$value = strtolower($value);
return str_replace(':', '|', $value);
case 'boolean':
if ('true' == trim(strtolower($value))) {
$value = trim(strtolower($value));
if ('true' === $value) {
$value = 1;
}
if ('false' == trim(strtolower($value))) {
} else if ('false' === $value) {
$value = 0;
}
return $value ? '1' : '0';
@ -457,7 +457,7 @@ class AttributeValidationTool
return true;
case 'link':
// Moved to a native function whilst still enforcing the scheme as a requirement
return filter_var($value, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED) && !preg_match("#\n#", $value);
return (bool)filter_var($value, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED);
case 'hex':
return ctype_xdigit($value);
case 'target-user':
@ -571,7 +571,7 @@ class AttributeValidationTool
if (self::isPositiveInteger($value) && $value <= 4294967295) {
return true;
}
return __('AS number have to be integers between 1 and 4294967295');
return __('AS number have to be integer between 1 and 4294967295');
}
throw new InvalidArgumentException("Unknown type $type.");
}