Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Deep imports of `src/validators/local/*` must use named exports instead of the removed default object exports, for example `import { acceptanceLocalValidator } from '@client-side-validations/client-side-validations/src/validators/local/acceptance'`
- Remove the unused `addClass` and `removeClass` exports from `src/utils.js`
- Explicitly remove dead \`inputs\` and \`validate_inputs\` entries from \`ClientSideValidations.selectors\`; only \`forms\` is read by the runtime`
* [BUGFIX] Correctly skip validation for elements where `data-csv-validate` is explicitly set to `"false"`

## 24.0.0 / 2026-04-19
* [FEATURE] Breaking change: Remove the jQuery runtime dependency and the old jQuery plugin aliases from the published JavaScript assets
Expand Down
2 changes: 1 addition & 1 deletion dist/client-side-validations.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/client-side-validations.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const validatorsFor = (elementName, validators) => {

const getValidationInputs = (form) => {
return Array.from(form.elements).filter((element) => {
if (element.dataset.csvValidate == null || element.disabled) {
if (element.dataset.csvValidate !== 'true' || element.disabled) {
return false
}

Expand Down
20 changes: 20 additions & 0 deletions test/javascript/public/test/form_builders/validateForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,26 @@ QUnit.test('Disable client side validations on all child inputs', function (asse
assert.notOk(input.parentElement.querySelector('label.message'))
})

QUnit.test('Validate form with an input with csvValidate set to false (async)', function (assert) {
var done = assert.async()
var form = document.getElementById('new_user')
var input = document.getElementById('user_name')

input.value = ''
input.dataset.csvValidate = 'false'

form.requestSubmit()

setTimeout(function () {
var iframe = document.querySelector('iframe')
var response = iframe && iframe.contentDocument && iframe.contentDocument.querySelector('#response')

assert.notOk(input.parentElement.classList.contains('field_with_errors'), 'Input should not have errors because validation was skipped')
assert.ok(response, 'Form should have been submitted successfully')
done()
}, 250)
})

QUnit.test('Disable ignores non-element nodes in mixed collections', function (assert) {
var input = document.getElementById('user_name')
var textNode = document.createTextNode('ignored node')
Expand Down
2 changes: 1 addition & 1 deletion vendor/assets/javascripts/rails.validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@
};
const getValidationInputs = form => {
return Array.from(form.elements).filter(element => {
if (element.dataset.csvValidate == null || element.disabled) {
if (element.dataset.csvValidate !== 'true' || element.disabled) {
return false;
}
return isVisible(element);
Expand Down