Question on the `validate` method (<https://api.cf...
# cfwheels
a
Question on the
validate
method (https://api.cfwheels.org/v1.4.5#validate)... this allows one to set validation handlers to be called when validations happen. Do they occur before, after, or instead of CFWheels' built-in-based-on-the-DB-schema validations? I don't see comment one way or the other on https://guides.cfwheels.org/docs/object-validation. Context: I have a property that is backed by a nullable date in the DB. By the time one of my bespoke validation handlers is called, will the inbuilt validation already have pushed back if the passed value is
"slartibartfast"
(or some other non-date value), or does my handler still need to guard against it being a date? I am presuming validation fails could be a cumulative thing, so I do need to guard against it. In this case I at least have to do a null-check before I do anytime timeframe validations on the value, I guess.
n
My coffee hasn't kicked in yet, but I think the DB schema validations are the first to be loaded in: https://github.com/cfwheels/cfwheels/blob/master/wheels/model/initialization.cfm#L130 then anything in the model file is "in addition to" those db schema requirements. The validation methods used are the same as if you'd specified them in the model file manually (i.e, validatesPresenceOf for a non nullable column) so adding additional validation would be just a duplication. IIRC you can turn off that behavior via
automaticValidations
which is on by default. As to what order the validations on each property kick in with, I'm unsure off the top of my head
1
a
Thanks man.