KD2 Framework  Check-in [c697e94176]

Overview
Comment:Form: fix issue with max/min and numeric strings
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | 5.6
Files: files | file ages | folders
SHA1: c697e941767cc1071ed8d1e3addbb7b029dfb714
User & Date: bohwaz on 2020-09-08 16:36:38
Other Links: manifest | tags
Context
2021-02-12
13:41
Smartyer: fix issue with magic getter objects check-in: 86764e2ca1 user: bohwaz tags: 5.6, trunk
2020-09-08
16:36
Form: fix issue with max/min and numeric strings check-in: c697e94176 user: bohwaz tags: 5.6, trunk
2020-09-01
10:15
Smartyer: fix issue with literal blocks check-in: 5a34e78508 user: bohwaz tags: 5.6, trunk
Changes

Modified src/lib/KD2/Form.php from [0cecc83ddf] to [5cd82f63d3].

458
459
460
461
462
463
464










465

466

467
468
469

470
471
472
473
474
475
476
			case 'json':
				return json_decode($value) !== null;
			case 'lt':
				return isset($params[0]) && isset($source[$params[0]]) && $value < $source[$params[0]];
			case 'lte':
				return isset($params[0]) && isset($source[$params[0]]) && $value <= $source[$params[0]];
			case 'max':










				$size = is_array($value) ? count($value) : (is_numeric($value) ? $value : strlen($value));

				return isset($params[0]) && $size <= $params[0];

			case 'min':
				$size = is_array($value) ? count($value) : (is_numeric($value) ? $value : strlen($value));
				return isset($params[0]) && $size >= $params[0];

			case 'not_in':
				return !in_array($value, $params);
			case 'numeric':
				return is_numeric($value);
			case 'present':
				return isset($source[$key]);
			case 'regex':







>
>
>
>
>
>
>
>
>
>
|
>
|
>
|
<
|
>







458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479

480
481
482
483
484
485
486
487
488
			case 'json':
				return json_decode($value) !== null;
			case 'lt':
				return isset($params[0]) && isset($source[$params[0]]) && $value < $source[$params[0]];
			case 'lte':
				return isset($params[0]) && isset($source[$params[0]]) && $value <= $source[$params[0]];
			case 'max':
			case 'min':
				if (is_array($value)) {
					$size = count($value);
				}
				elseif (isset($rules['numeric']) || isset($rules['int']) || isset($rules['integer'])) {
					$size = (int) $value;
				}
				else {
					$size = strlen($value);
				}

				if ($rule_name == 'max') {
					return isset($params[0]) && $size <= $params[0];
				}
				else {

					return isset($params[0]) && $size >= $params[0];
				}
			case 'not_in':
				return !in_array($value, $params);
			case 'numeric':
				return is_numeric($value);
			case 'present':
				return isset($source[$key]);
			case 'regex':