New on the blog: Validations Beyond Presence — con...
# wheels-dev
p
New on the blog: Validations Beyond Presence — conditional rules, custom validators, and enum integration in Wheels 4.0. <https://blog.wheels.dev/posts/validations-conditional-enum/ > What it covers: • The full validator surface in one worked model — presence, scoped uniqueness, format, length, numericality, inclusion/exclusion, confirmation • Conditional validation with
condition
/
unless
/
when
— and why those are a fixed-grammar string parser, NOT
Evaluate()
(bad expressions silently skip in production) • Custom
validate()
/
validateOnCreate()
/
validateOnUpdate()
— register a method name, fail by calling
addError()
(the return value is ignored — the #1 gotcha) •
enum()
— one call that auto-registers
validatesInclusionOf
, generates
isDraft()
-style checkers, and creates per-value scopes • Reading errors right:
errorsOn()
returns an array of
{property, message, name}
STRUCTS — loop and read
.message
, don’t print the struct Plus a “sharp edges” section: scoped uniqueness isn’t a DB constraint, presence is skipped on columns with a DB default, confirmation errors land on the virtual
passwordConfirmation
property, and
allowBlank
defaults to false everywhere.