Skip to content

various format-with validators on one page. #30

Open
@tec

Description

@tec

If I understand it correctly, the following line in lib/validatious-on-rails/model_validations.rb adds all the client-side and remote validations to one string and then to the html. The unless in the string inhibits identical validations to be added several times.

validator_js << v.to_js
unless existing_validators.present?
&& /#{v.name}/ =~ existing_validators

Unfortunately I had a case where several validations both had the v.name 'format-with', but with different formats. So one of them was not displayed. i solved it by also matching v.to_class in the unless. v.to_class differs because of the generated (random) params id.

validator_js << v.to_js
unless existing_validators.present?
&& /#{v.name}/ =~ existing_validators
&& /#{v.to_class}/ =~ existing_validators

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions