Skip to content

[6.x] Add min and max validation rules when configured as zero - #15175

Merged
jasonvarga merged 1 commit into
6.xfrom
min-max-zero-rules
Aug 12, 2026
Merged

[6.x] Add min and max validation rules when configured as zero#15175
jasonvarga merged 1 commit into
6.xfrom
min-max-zero-rules

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request fixes an issue where a min or max of 0 on the Integer and Float fieldtypes was silently ignored, so the value never got validated.

This was happening because Integer::rules() and Floatval::rules() used truthy checks (if ($min = $this->config('min'))), which treat a configured 0 as unset. Since #12395 made Min, Max and Step user-facing config fields on both fieldtypes, it became easy to hit — setting Min to 0 to prevent negative numbers did nothing at all.

This PR fixes it by checking for null instead of truthiness.

Related: #8932
Caused by #12395

`Integer::rules()` and `Floatval::rules()` used truthy checks, so a `min` or `max` of `0` was treated as unset and silently dropped from validation.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jasonvarga
jasonvarga merged commit 355aa3f into 6.x Aug 12, 2026
65 checks passed
@jasonvarga
jasonvarga deleted the min-max-zero-rules branch August 12, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants