Skip to content
Snippets Groups Projects

Issue #3522116: ConfigFormBase produces an error when saving empty number value from the form to a numeric schema item: This value should be of the correct primitive type

Open Issue #3522116: ConfigFormBase produces an error when saving empty number value from the form to a numeric schema item: This value should be of the correct primitive type
Files
2
@@ -40,10 +40,10 @@ public function validate($value, Constraint $constraint): void {
if ($typed_data instanceof BooleanInterface && !(is_bool($value) || $value === 0 || $value === '0' || $value === 1 || $value == '1')) {
$valid = FALSE;
}
if ($typed_data instanceof FloatInterface && filter_var($value, FILTER_VALIDATE_FLOAT) === FALSE) {
if ($typed_data instanceof FloatInterface && ($value !== '' && filter_var($value, FILTER_VALIDATE_FLOAT) === FALSE)) {
$valid = FALSE;
}
if ($typed_data instanceof IntegerInterface && filter_var($value, FILTER_VALIDATE_INT) === FALSE) {
if ($typed_data instanceof IntegerInterface && ($value !== '' && filter_var($value, FILTER_VALIDATE_INT) === FALSE)) {
$valid = FALSE;
}
if ($typed_data instanceof DecimalInterface && !preg_match('/^[+-]?((\d+(\.\d*)?)|(\.\d+))$/i', $value)) {
Loading