auraphp / Aura.Filter

Validate and sanitize arrays and objects.
MIT License
159 stars 33 forks source link

Add `useBlankField` to SanitizeSpec #130

Closed jakejohns closed 2 years ago

jakejohns commented 7 years ago

RE: #119

Thoughts?

This makes SanitizeSpec work like this:

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.

harikt commented 7 years ago

@pmjones would you like to review this PR ?