I’m looking for a way to trim these values in the same way I would in Ecto, but from reading the documentation and reading the code, it doesn’t seem to me like it’s possible.
I’d like to know if there’s a motivation behind this design choice, or if a discussion & PR to make that possible could be entertained (if so, I’d be more than happy to contribute to this amazing framework ).
Honestly, that was added so long ago its hard to say what the original rationale was
Ash strings (by default), cast to nil.
We have the nil_items? constraint, which rejects nil values. For us empty_values is a separate kind of thing, representing when the entire list is empty.
I think what you want is a new constraint, called remove_nil_items? that will remove nil items instead of making them an error if they exist.
I would say that we should move the is_nil check to after applying constraints to the inner items, primarily because types could even theoretically do the reverse, taking a nil item and casting it to a value.
I also wouldn’t personally consider it a breaking change, but rather a bug fix. If nil_items?: false can still produce an array with nil items, that counts as a bug in my book
Please open an issue for these so we can make sure to address them (or of course a PR )