Repository navigation
Conversation
…nt's rules; dates without a DateFormat work before 1970 and on the client (pradosoft#1497)
belisoful
force-pushed
the
claude/1497-compare-validator-client-rules
branch
from
November 21, 2026 03:21
d71b15f to
9aaa18d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1497 (WebControls: validators).
TCompareValidatorandTDataTypeValidatorconvert values with the same rules on the server and the client.Server bugs:
TCompareValidatorcomparedStringvalues with==, so1e3equaled1000and01equaled1.TCompareValidatorcastIntegerandFloatvalues with no check, soabcwas 0. With aDateFormat, an invalid date parsed as the current time.ControlToComparealways failed, whatever the data type.DateFormat, both validators requiredstrtotime() > 0, which rejected the epoch and every date before 1970.TCompareValidatorcomparedfalsewithfalsefor two invalid dates, so they were equal.TDataTypeValidatoraccepted aFloatwith an exponent (1e5), which the client rejects.Client bug:
Date.SimpleParse()turned a missing format into the string"undefined". So without aDateFormat, the clientTCompareValidatorandTDataTypeValidatorrejected every date.Fix, following the client's rules:
TValidationDataType::convert()converts a value, and returns null when it does not convert:Integer: optional sign and digits.Float: optional sign, digits, and a.fraction, without an exponent.Date:TSimpleDateFormatterwith a format, elsestrtotime().String: unchanged.TCompareValidator: an input that does not convert fails, and a value to compare that does not convert passes. Strings compare withstrcmp().TDataTypeValidatorchecks withconvert().Date.SimpleParse()treats a missing format as empty, uses theDateparser, and returns null for an invalid date.Tests:
TCompareValidatorTestandTDataTypeValidatorTest; 18 of their cases fail on master.Date.SimpleParse(), compare, and data type; 5 fail on master.composer jstestpass; the validator tests pass on PHP 8.2 to 8.5; php-cs-fixer and PHPStan are clean.