Closed jakejohns closed 2 years ago
I was thinking about patching the SanatizeSpec to be able to pass a callable to useBlankValue that would take the subject as an arg, but i don't actually think that's the way.
I wonder if an added method useBlankField()
(or something like that) would be useful here, to indicate "if blank, use the value from this field".
@jakejohns Any further thoughts here?
Often I wish to set a field (ie.
slug
) to the value of another field (ie. title) if the former is blank, then sanitize it further. I think I can accomplish this now with some magic strings like this:But that's kind of awkward/magical/weird.
Any suggestions? Think we need a PR?
I was thinking about patching the
SanatizeSpec
to be able to pass acallable
touseBlankValue
that would take the subject as an arg, but i don't actually think that's the way.ie.:
Maybe what I want isn't really a "blank" value, but a "defaultTo" or something? and should encompass a new set of logic?
Thoughts?