- Issue created by @marksmith
- 🇮🇪Ireland marksmith
The following code appears to solve the issue:
/** * {@inheritdoc} */ public function getConstraints(array $settings): array { $constraints['Regex']['pattern'] = '/^[+-]?((\d+(\.\d*)?)|(\.\d+))$/i'; // Handle range constraints if ((isset($settings['min']) && $settings['min'] !== '') || (isset($settings['max']) && $settings['max'] !== '')) { // If both min and max are set, use notInRangeMessage if ((isset($settings['min']) && $settings['min'] !== '') && (isset($settings['max']) && $settings['max'] !== '')) { $min = $settings['min']; $max = $settings['max']; $constraints['Range']['min'] = $min; $constraints['Range']['max'] = $max; $constraints['Range']['notInRangeMessage'] = $this->t('%name: the value must be between %min and %max.', [ '%name' => $settings['name'], '%min' => $min, '%max' => $max, ]); } // Only min is set elseif (isset($settings['min']) && $settings['min'] !== '') { $min = $settings['min']; $constraints['Range']['min'] = $min; $constraints['Range']['minMessage'] = $this->t('%name: the value may be no less than %min.', [ '%name' => $settings['name'], '%min' => $min, ]); } // Only max is set elseif (isset($settings['max']) && $settings['max'] !== '') { $max = $settings['max']; $constraints['Range']['max'] = $max; $constraints['Range']['maxMessage'] = $this->t('%name: the value may be no greater than %max.', [ '%name' => $settings['name'], '%max' => $max, ]); } } return $constraints; }
I suppose, something similar should also be added to the IntegerType.php as well.
- 🇺🇸United States apmsooner
Okay thanks for the report. I'll put together a patch soon for this issue.
-
apmsooner →
committed 277c6878 on 3.1.x
Issue #3518147 by apmsooner, marksmith: Cannot set both min and max...
-
apmsooner →
committed 277c6878 on 3.1.x