Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not give error of which field has errors #3

Open
espen opened this issue Oct 3, 2023 · 10 comments
Open

Does not give error of which field has errors #3

espen opened this issue Oct 3, 2023 · 10 comments

Comments

@espen
Copy link
Owner

espen commented Oct 3, 2023

{% name %}
{% email %}
{% street 'Adresse', 'data-required="true"' %}
{% street 'Sted', 'data-required="true"' %}

results in 'booking form must not have more than 1 '. Should include the field name 'street'

@espen
Copy link
Owner Author

espen commented Oct 3, 2023

Can you have a look @melashu ?

@melashu
Copy link

melashu commented Oct 3, 2023

Hi @espen, I'm still not sure what you're asking me. Could you please give me more details?

@espen
Copy link
Owner Author

espen commented Oct 4, 2023

When the Liquid input is as above it will not give proper error message. It gives error "booking form must not have more than 1". but it should include the error field: "booking form must not have more than 1 street". It might be related to using an array of values so the error does not know which field caused the error.

I am using this:
validates_liquid_tag :booking_form, tag: ['date_of_birth', 'national_id_no', 'street', 'postal_code', 'city', 'country_code', 'count', 'note'], max: 1, presence: false, :allow_blank => true

@melashu
Copy link

melashu commented Oct 5, 2023

Hi @espen, this happens because {% street 'Sted', 'data-required=" true"' %} is treated as an attribute that is not present in the tag list instead ofstreet. For example if you make it like "{% name %} {% email %} {% street %} {% street %}" you can get a correct error message. I think we need to write another logic that can extract such like pattern from an array of tags!

@melashu
Copy link

melashu commented Oct 5, 2023

we didn't consider this in the previous senario

@espen
Copy link
Owner Author

espen commented Oct 5, 2023

I thought that was already working. Is it just a problem when using an array, not a string? I thought there were tests for this pattern

@melashu
Copy link

melashu commented Oct 5, 2023

Yes this is when there is an array, for string it works fine and there is a test for that too

@melashu
Copy link

melashu commented Oct 5, 2023

look this

  it "must be valid when using more complex tag" do
        @mixin.content = "{% josh_is_awesome foobar, data-required='true' %}"
        @mixin.valid?
        @mixin.errors.full_messages.any? { |e| e == "You must supply {% josh_is_awesome %} in your content" }.must_equal false
      end

@espen
Copy link
Owner Author

espen commented Oct 6, 2023

Ok, can you make a failing test for using with array? Then see if you can fix it.

@melashu
Copy link

melashu commented Oct 6, 2023

Sure, I will check it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants