fields
fields copied to clipboard
fix: accept nil values when validating URLs
without this, it's impossible to allow nil values.
nil constraints should be set elsewhere and be allowed in this library from my pov.
Codecov Report
Merging #150 (68995a5) into main (8c57df9) will not change coverage. The diff coverage is
100.00%
.
@@ Coverage Diff @@
## main #150 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 23 23
Lines 189 190 +1
=========================================
+ Hits 189 190 +1
Files Changed | Coverage Δ | |
---|---|---|
lib/url.ex | 100.00% <100.00%> (ø) |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
Hi @iloveitaly 👋 Could you please clarify the use case for a nil value being OK? ðŸ’
Not all fields on my model are required. In this case, a nil value could be passed and converted into a NULL
on the DB side. Essentially, I want to leave a field blank.
Hmm ... this feels like something that can be checked in the changeset/2
function
or defined declaratively in the schema
...
I'm not against merging/publishing this change necessarily,
I'm just curious if this can be achieved without allowing nil
(NULL
) values for URLs
because nil
isn't a valid URL
... ðŸ’
@nelsonic do you know what I need to add to:
schema "things" do
field :url, Fields.Url
end
so a null/nil value is accepteed?
@nelsonic friendly ping here!