Skip to content

Commit 650e0a9

Browse files
committed
fix: rangeMin and rangeMax resolver logic.
1 parent 456f18b commit 650e0a9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Types/Field/NumberField.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace WPGraphQLGravityForms\Types\Field;
1313

14+
use GFCommon;
1415
use GF_Field_Number;
1516
use WPGraphQLGravityForms\Types\Enum\NumberFieldFormatEnum;
1617
use WPGraphQLGravityForms\Types\Field\FieldProperty;
@@ -84,22 +85,26 @@ public function get_type_fields() : array {
8485
'type' => 'Float',
8586
'description' => __( 'Minimum allowed value for a number field. Values lower than the number specified by this property will cause the field to fail validation.', 'wp-graphql-gravity-forms' ),
8687
'resolve' => function( GF_Field_Number $root ) {
87-
if ( '' === $root['rangeMin'] ) {
88+
if ( ! isset( $root->rangeMin ) ) {
8889
return null;
8990
}
9091

91-
return (float) $root['rangeMin'];
92+
$numeric_min = isset( $root->numberFormat ) && 'decimal_comma' === $root->numberFormat ? GFCommon::clean_number( $root->rangeMin, 'decimal_comma' ) : $root->rangeMin;
93+
94+
return is_numeric( $numeric_min ) ? (float) $numeric_min : null;
9295
},
9396
],
9497
'rangeMax' => [
9598
'type' => 'Float',
9699
'description' => __( 'Maximum allowed value for a number field. Values higher than the number specified by this property will cause the field to fail validation.', 'wp-graphql-gravity-forms' ),
97100
'resolve' => function( GF_Field_Number $root ) {
98-
if ( '' === $root['rangeMax'] ) {
101+
if ( ! isset( $root->rangeMin ) ) {
99102
return null;
100103
}
101104

102-
return (float) $root['rangeMax'];
105+
$numeric_min = isset( $root->numberFormat ) && 'decimal_comma' === $root->numberFormat ? GFCommon::clean_number( $root->rangeMin, 'decimal_comma' ) : $root->rangeMin;
106+
107+
return is_numeric( $numeric_min ) ? (float) $numeric_min : null;
103108
},
104109
],
105110
]

0 commit comments

Comments
 (0)