First, if field is blank and blank_field is set, it will set field to the value of blank_field.
It then continues as before. This differs from the usage of blank_value, which is simply used as a default value and incurs no further processing. In my use cases, when I want to "sanitize a field to the value of another field" I usually want to start with that value, and then transform it (eg. creating a default "slug" from a "title" property)
Here, setting blank_field does not set allow_blank. If blank_field is also blank, and field does not allow_blank, it will still fail, and if blank_value is set, it will use that in the end.
RE: #119
Thoughts?
This makes
SanitizeSpec
work like this:First, if field is blank and
blank_field
is set, it will setfield
to the value ofblank_field
.It then continues as before. This differs from the usage of
blank_value
, which is simply used as a default value and incurs no further processing. In my use cases, when I want to "sanitize a field to the value of another field" I usually want to start with that value, and then transform it (eg. creating a default "slug" from a "title" property)Here, setting
blank_field
does not setallow_blank
. Ifblank_field
is also blank, andfield
does notallow_blank
, it will still fail, and ifblank_value
is set, it will use that in the end.