Skip to content
Merged
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
22 changes: 2 additions & 20 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['3.1', '3.2', '3.3', '3.4', '4.0']
gemfile: [rails_6.1, rails_7.0, rails_7.1, rails_7.2, rails_8.0, rails_8.1]
ruby-version: ['3.2', '3.3', '3.4', '4.0']
gemfile: [rails_7.2, rails_8.0, rails_8.1]
channel: ['stable']

include:
Expand All @@ -40,24 +40,6 @@ jobs:
channel: 'experimental'

exclude:
- ruby-version: '3.1'
gemfile: rails_8.0
- ruby-version: '3.1'
gemfile: rails_8.1
- ruby-version: '3.2'
gemfile: rails_6.1
- ruby-version: '3.3'
gemfile: rails_6.1
- ruby-version: '3.4'
gemfile: rails_6.1
- ruby-version: '3.4'
gemfile: rails_7.0
- ruby-version: '4.0'
gemfile: rails_6.1
- ruby-version: '4.0'
gemfile: rails_7.0
- ruby-version: '4.0'
gemfile: rails_7.1
- ruby-version: '4.0'
gemfile: rails_7.2

Expand Down
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ plugins:
- rubocop-rake

AllCops:
TargetRailsVersion: 6.1
TargetRubyVersion: 3.1
TargetRailsVersion: 7.2
TargetRubyVersion: 3.2
NewCops: enable
DisplayStyleGuide: true
ExtraDetails: true
Expand Down
15 changes: 0 additions & 15 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
# frozen_string_literal: true

appraise 'rails-6.1' do
gem 'rails', '~> 6.1.0'
gem 'sqlite3', '~> 1.7'
gem 'concurrent-ruby', '< 1.3.5' # Ref: rails/rails#54260
end

appraise 'rails-7.0' do
gem 'rails', '~> 7.0.0'
gem 'sqlite3', '~> 1.7'
end

appraise 'rails-7.1' do
gem 'rails', '~> 7.1.0'
end

appraise 'rails-7.2' do
gem 'rails', '~> 7.2.0'
end
Expand Down
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
- `data-validate` => `data-csv-validate`
* [FEATURE] Use data attributes instead of `jQuery.data()`
* [FEATURE] Drop Internet Explorer and other older browsers support
* [FEATURE] Drop Ruby < 3.1
* [FEATURE] Drop Ruby < 3.2
* [FEATURE] Drop Rails < 7.2
* [FEATURE] Drop jQuery < 3.7.1 Compatibility
* [BUGFIX] Allow `proc` values in length validator options
* [ENHANCEMENT] Update QUnit to 2.24.3
* [ENHANCEMENT] Test against Ruby 3.4
* [ENHANCEMENT] Update QUnit to 2.25.0
* [ENHANCEMENT] Test against Ruby 3.4 and 4.0

## 22.3.1 / 2025-01-29

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![Coverage Status](https://coveralls.io/repos/github/DavyJonesLocker/client_side_validations/badge.svg?branch=main)](https://coveralls.io/github/DavyJonesLocker/client_side_validations?branch=main)


`ClientSideValidations` made easy for your Rails 6.1, 7.x, and 8.0 applications!
`ClientSideValidations` made easy for your Rails 7.2 and 8.x applications!

## Project Goals ##

Expand Down Expand Up @@ -56,7 +56,7 @@ config/initializers/client_side_validations.rb

Instructions depend on your technology stack.

Please note that CSV depends on jQuery >= 1.12.4 (jQuery slim is fine).
Please note that CSV depends on jQuery >= 3.7.1 (jQuery slim is fine).

#### When using Webpacker ####

Expand Down Expand Up @@ -99,7 +99,7 @@ Make sure that `jquery-rails` is part of your bundled gems and `application.js`,
otherwise add:

```ruby
gem 'jquery-rails', '~> 4.3'
gem 'jquery-rails'
```

to your `Gemfile`, run `bundle`, and add
Expand Down
8 changes: 4 additions & 4 deletions client_side_validations.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
spec.email = ['tagliala.dev@gmail.com', 'bcardarella@gmail.com']

spec.summary = 'Client Side Validations'
spec.description = 'Client Side Validations made easy for your Rails 6.1, 7.x, and 8.0 applications'
spec.description = 'Client Side Validations made easy for your Rails 7.2 and 8.x applications'
spec.homepage = 'https://github.com/DavyJonesLocker/client_side_validations'
spec.license = 'MIT'

Expand All @@ -25,8 +25,8 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

spec.platform = Gem::Platform::RUBY
spec.required_ruby_version = '>= 3.1'
spec.required_ruby_version = '>= 3.2'

spec.add_dependency 'js_regex', '~> 3.7'
spec.add_dependency 'rails', '>= 6.1'
spec.add_dependency 'js_regex', '>= 3.14'
spec.add_dependency 'rails', '>= 7.2'
end
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.

26 changes: 0 additions & 26 deletions gemfiles/rails_6.1.gemfile

This file was deleted.

25 changes: 0 additions & 25 deletions gemfiles/rails_7.0.gemfile

This file was deleted.

25 changes: 0 additions & 25 deletions gemfiles/rails_7.1.gemfile

This file was deleted.

11 changes: 3 additions & 8 deletions lib/client_side_validations/action_view/form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,11 @@ def form_for(record, options = {}, &block)
form_with(**options, &block)
end

def apply_csv_form_for_options!(record, object, options)
def apply_csv_form_for_options!(object, options)
options[:html][:validate] = true if options[:validate]
options[:html][:method] ||= options[:method]

# TODO: remove else branch when minimum compatible version when dropping 6.1 support
if method(:apply_form_for_options!).arity == 2
apply_form_for_options! object, options
else
apply_form_for_options! record, object, options
end
apply_form_for_options! object, options
end

def fields_for(record_name, record_object = nil, options = {}, &)
Expand All @@ -69,7 +64,7 @@ def check_record(record, options)
raise ArgumentError, 'First argument in form cannot contain nil or be empty' unless object

object_name = options[:as] || model_name_from_record_or_class(object).param_key
apply_csv_form_for_options!(record, object, options)
apply_csv_form_for_options!(object, options)
end

[record, object_name]
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@client-side-validations/client-side-validations",
"description": "Client Side Validations made easy for your Rails 6.1, 7.x, and 8.0 applications",
"description": "Client Side Validations made easy for your Rails 7.2 and 8.x applications",
"repository": {
"type": "git",
"url": "git+https://github.com/DavyJonesLocker/client_side_validations.git"
Expand Down Expand Up @@ -31,7 +31,7 @@
"eslint-plugin-compat": "^6.0.2",
"neostandard": "^0.12.2",
"puppeteer-core": "^24.34.0",
"rollup": "^4.54.0",
"rollup": "^4.55.1",
"rollup-plugin-copy": "^3.5.0"
},
"peerDependencies": {
Expand Down
22 changes: 10 additions & 12 deletions test/action_view/cases/test_form_with_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,18 @@ def test_form_with_file_field
assert_dom_equal expected, output_buffer
end

if Rails.version >= '7.0'
def test_form_with_file_multiple_include_hidden
form_with(model: @post, validate: true) do |f|
concat f.file_field(:cost, multiple: true, include_hidden: true)
end

validators = { 'post[cost][]' => { presence: [{ message: I18n.t('errors.messages.blank') }] } }
expected = whole_form_with('/posts', validators: validators, file: true) do
hidden_input('post[cost][]') +
form_field('input', id: 'post_cost', name: 'post[cost][]', type: 'file', multiple: 'multiple')
end
def test_form_with_file_multiple_include_hidden
form_with(model: @post, validate: true) do |f|
concat f.file_field(:cost, multiple: true, include_hidden: true)
end

assert_dom_equal expected, output_buffer
validators = { 'post[cost][]' => { presence: [{ message: I18n.t('errors.messages.blank') }] } }
expected = whole_form_with('/posts', validators: validators, file: true) do
hidden_input('post[cost][]') +
form_field('input', id: 'post_cost', name: 'post[cost][]', type: 'file', multiple: 'multiple')
end

assert_dom_equal expected, output_buffer
end

def test_form_with_check_box
Expand Down
20 changes: 9 additions & 11 deletions test/action_view/cases/test_legacy_form_with_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,17 @@ def test_form_with_file_field
assert_dom_equal expected, output_buffer
end

if Rails.version >= '7.0'
def test_form_with_file_multiple_include_hidden
form_with(model: @post) do |f|
concat f.file_field(:cost, multiple: true, include_hidden: true)
end

expected = whole_form_with('/posts', file: true) do
hidden_input('post[cost][]') +
form_field('input', id: 'post_cost', name: 'post[cost][]', type: 'file', multiple: 'multiple')
end
def test_form_with_file_multiple_include_hidden
form_with(model: @post) do |f|
concat f.file_field(:cost, multiple: true, include_hidden: true)
end

assert_dom_equal expected, output_buffer
expected = whole_form_with('/posts', file: true) do
hidden_input('post[cost][]') +
form_field('input', id: 'post_cost', name: 'post[cost][]', type: 'file', multiple: 'multiple')
end

assert_dom_equal expected, output_buffer
end

def test_form_with_check_box
Expand Down
2 changes: 1 addition & 1 deletion test/javascript/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def call(env)
use AssetPath, urls: ['/vendor/assets/javascripts'], root: File.expand_path('../', $LOAD_PATH.find { |p| p.include?('jquery-rails') })

DEFAULT_JQUERY_VERSION = '3.7.1'
QUNIT_VERSION = '2.24.3'
QUNIT_VERSION = '2.25.0'

helpers do
def jquery_version
Expand Down
2 changes: 1 addition & 1 deletion vendor/assets/javascripts/rails.validations.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Client Side Validations JS - v0.5.0 (https://github.com/DavyJonesLocker/client_side_validations)
* Copyright (c) 2025 Geremia Taglialatela, Brian Cardarella
* Copyright (c) 2026 Geremia Taglialatela, Brian Cardarella
* Licensed under MIT (https://opensource.org/licenses/mit-license.php)
*/

Expand Down