-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NEW Validate DBFields #11408
NEW Validate DBFields #11408
Conversation
00a13da
to
1f4a38a
Compare
926371b
to
9c169bd
Compare
9614506
to
2b9af83
Compare
src/Core/Validation/FieldValidation/CompositeFieldValidator.php
Outdated
Show resolved
Hide resolved
5242fd9
to
158a9d4
Compare
There's a bunch of stuff still not addressed. |
2b7c95c
to
913734a
Compare
913734a
to
c4d4886
Compare
@GuySartorelli after rebasing in the template work I needed to make a small change to a test in CastingServiceTest.php as DBCurrency extends DBDecimal and getValue() now returns a float, previously the test was expecting a string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good, but found a few anomolies while testing
d18eeeb
to
1a6c9ce
Compare
873e01d
to
a5133fd
Compare
ed9c52d
to
a8ca5e9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be the last thing before the code PRs can be merged.
Don't bother rerunning kitchen sink after making this change
a8ca5e9
to
ec45390
Compare
Issue #11403
Adds a $value param to ValidationResult. This is mainly to make debugging easier.Note that while this PR adds support to FormField for FieldValidators, I haven't actually added the FieldValidators to the FormField's in this PR, as too much would be changing at once and many things would break in CI. Instead I've split off a separate issue for that to be done after this has been mergedHave removed FormField changesThere is some type conversion going on in
DBField::setValue()
, which happens before validation, though I'm trying to not be too permissive as this PR is essentially adding strict typing to DBFields. Some examples:'t'
will get converted totrue
A few things that we might want to consider changing (easiest done as follow up cards):
DBBoolean should possibly stop accepting values such as 't'will retain backward compatibilityDBDate currently accepts a range of dates and attempts to fix things. Changes were made in this PR, though one not unexpected and not great side effect is that a value that previously threw an error duringHave reverted changes, now behaves like CMS 5DBDate::setValue()
"03-03-04" now gets turned into "2003-03-04". The existing behaviour of turning "0" into "1970-01-01" remain. Perhaps we should be stricter and only allow 'Y-m-d' style inputs.Also to answer the question "why are we even doing this when you can just get the database to do this?". It's because we cannot give any guarantees is MySQL is set in strict mode (will complain and not update value when invalid) vs not in strict mode (will truncate and insert). Also, FieldValidator is an abstract class that will be shared with FormField validation, which doesn't even touch the database. Also, things like EmailFieldValidator can't be validated by MySQL.