fields icon indicating copy to clipboard operation
fields copied to clipboard

fix: accept nil values when validating URLs

Open iloveitaly opened this issue 1 year ago • 6 comments

without this, it's impossible to allow nil values.

nil constraints should be set elsewhere and be allowed in this library from my pov.

iloveitaly avatar Aug 21 '23 23:08 iloveitaly

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

codecov[bot] avatar Aug 21 '23 23:08 codecov[bot]

Hi @iloveitaly 👋 Could you please clarify the use case for a nil value being OK? 💭

nelsonic avatar Aug 22 '23 00:08 nelsonic

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.

iloveitaly avatar Aug 22 '23 01:08 iloveitaly

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 avatar Aug 23 '23 13:08 nelsonic

@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?

iloveitaly avatar Aug 25 '23 19:08 iloveitaly

@nelsonic friendly ping here!

iloveitaly avatar Sep 15 '23 11:09 iloveitaly