Commit 07317b2a authored by Elias Villiger's avatar Elias Villiger
Browse files

Implement max test #5309

parent 803fecf1
......@@ -187,7 +187,7 @@ const ERROR_PLAY_SQL_FILE = 1080;
const ERROR_MISSING_FILE_NAME = 1081;
const ERROR_MAX_FILE_SIZE_TOO_BIG = 1082;
const ERROR_SMALLER_THAN_MIN = 1083;
const ERROR_GREATER_THAN_MAX = 1084;
const ERROR_LARGER_THAN_MAX = 1084;
// Subrecord
const ERROR_SUBRECORD_MISSING_COLUMN_ID = 1100;
......
......@@ -44,12 +44,12 @@ class Sanitize {
$sanitizeClass = Support::setIfNotSet($formElement, FE_CHECK_TYPE, SANITIZE_DEFAULT);
$pattern = Support::setIfNotSet($formElement, FE_CHECK_PATTERN);
$min = Support::setIfNotSet($formElement, FE_MIN, null);
// $max
// $minMaxCompareMode
$max = Support::setIfNotSet($formElement, FE_MAX, null);
// TODO: $minMaxCompareMode
$errorCode = 0;
$errorText = '';
// Prepare checktype Check
// Prepare pattern check
switch ($sanitizeClass) {
case SANITIZE_ALLOW_PATTERN:
break;
......@@ -63,7 +63,7 @@ class Sanitize {
$pattern = $arr[$sanitizeClass];
break;
case SANITIZE_ALLOW_ALL: // no checktype specified.
case SANITIZE_ALLOW_ALL: // no checkType specified.
$pattern = '';
break;
......@@ -78,12 +78,16 @@ class Sanitize {
}
// Min/max check (only necessary if pattern check passed)
// minMaxCompareMode: Default richtet sich nach Type des FE (bei type date: string, ansonsten: numerical)
// TODO: minMaxCompareMode: Default richtet sich nach Type des FE (bei type date: string, ansonsten: numerical)
if ($errorCode == 0) {
if ($min !== null && $value < $min) {
$errorCode = ERROR_SMALLER_THAN_MIN;
$errorText = "Value '$value' is smaller than the allowed minimum of '$min'.";
}
if ($max !== null && $value > $max) {
$errorCode = ERROR_LARGER_THAN_MAX;
$errorText = "Value '$value' is larger than the allowed maximum of '$max'.";
}
}
if ($errorCode == 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment