Skip to content

Skip validation when csvValidate is false#1021

Closed
tagliala wants to merge 1 commit into
mainfrom
bugfix/fix-csv-validate-false
Closed

Skip validation when csvValidate is false#1021
tagliala wants to merge 1 commit into
mainfrom
bugfix/fix-csv-validate-false

Conversation

@tagliala

@tagliala tagliala commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Currently, the runtime only skips validation if the data-csv-validate attribute is missing. If it's explicitly set to "false", the element is still included in the validation inputs because "false" == null is false.

Change the check to ensure that only elements with csvValidate set to "true" are validated. This allows users to dynamically disable validation for specific elements by setting the attribute to "false".

Currently, the runtime only skips validation if the `data-csv-validate`
attribute is missing. If it's explicitly set to `"false"`, the element
is still included in the validation inputs because `"false" == null` is
false.

Change the check to ensure that only elements with `csvValidate` set to
`"true"` are validated. This allows users to dynamically disable
validation for specific elements by setting the attribute to `"false"`.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes the client-side-validations runtime so that form-level validation only runs for elements explicitly marked with data-csv-validate="true", allowing callers to skip validation by setting data-csv-validate="false" on specific elements.

Changes:

  • Update getValidationInputs to require element.dataset.csvValidate === 'true' (instead of only checking for null/undefined).
  • Add a QUnit regression test ensuring an input with csvValidate set to "false" doesn’t block form submission.
  • Document the bugfix in the changelog and propagate the runtime change into distributed JS bundles.

Reviewed changes

Copilot reviewed 3 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vendor/assets/javascripts/rails.validations.js Applies the stricter data-csv-validate === "true" gating to the Rails vendor runtime bundle.
src/index.js Updates the source implementation of getValidationInputs to validate only explicitly enabled inputs.
dist/client-side-validations.js Updates the compiled UMD bundle to match the new validation gating behavior.
dist/client-side-validations.esm.js Updates the compiled ESM bundle to match the new validation gating behavior.
test/javascript/public/test/form_builders/validateForm.js Adds a regression test covering data-csv-validate="false" on submit.
CHANGELOG.md Records the bugfix in the unreleased changelog section.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/index.js
const getValidationInputs = (form) => {
return Array.from(form.elements).filter((element) => {
if (element.dataset.csvValidate == null || element.disabled) {
if (element.dataset.csvValidate !== 'true' || element.disabled) {
@tagliala tagliala closed this Jun 3, 2026
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

Successfully merging this pull request may close these issues.

2 participants