You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code no longer produces validation failures after upgrading to 2.3
Steps to reproduce
Gemfile
# frozen_string_literal: truesource"https://rubygems.org"git_source(:github){|repo_name| "https://github.com/#{repo_name}"}# Works with this versiongem"reform",'2.2.4'gem"reform-rails",'~> 0.1',require: false# Fails with this version#gem "reform", '2.3.1'#gem "reform-rails", '~> 0.2', require: falsegem'dry-types','~> 0.14.1'
repro.rb
# frozen_string_literal: trueBundler.require### BEGIN COPY-PASTE FROM REFORM-RAILSrequire"reform"require"reform/form/active_model/model_validations"require"reform/form/active_model/form_builder_methods"require"reform/form/active_model"require"reform/form/active_model/validations"require"reform/form/multi_parameter_attributes"require"reform/active_record"ifdefined?(ActiveRecord)require"reform/mongoid"ifdefined?(Mongoid)Reform::Form.class_evaldoincludeReform::Form::ActiveModelincludeReform::Form::ActiveModel::FormBuilderMethodsincludeReform::Form::ActiveRecordifdefined?(ActiveRecord)includeReform::Form::Mongoidifdefined?(Mongoid)includeReform::Form::ActiveModel::Validationsend### END COPY-PASTEExample=Struct.new(:sorts)classExampleForm < Reform::FormVALID_SORTS=%w[namedate].freezeVALID_SORT_DIRECTIONS=%w[ascdesc].freezeproperty:sorts,default: [{by: :name,dir: :desc}]defsorts=(sort_strings)sorts=sort_strings.split(',').mapdo |sort|
by,dir=sort.split(':')errors[:sort] << "is not valid"unlessVALID_SORTS.include?(by)errors[:sort_direction] << "is not valid"unlessVALID_SORT_DIRECTIONS.include?(dir){by: by.underscore.to_sym,dir: dir.to_sym}endsuper(sorts)endendmodel=Example.newform=ExampleForm.new(model)res=form.validate({sorts: 'wutang:asc'})raise"Should be false"ifres
% bundle
% bundle exec ruby repro.rb
# Edit the gemfile to switch to reform 2.3
% bundle update
% bundle exec ruby repro.rb
Expected behavior
The input parameters should be invalid.
Actual behavior
The errors added are lost somewhere and the form is marked as valid.
System configuration
Reform version: Upgrading from 2.2.4 to 2.3.1 Reform-Rails version: Upgrading from 0.1 to 0.2
The text was updated successfully, but these errors were encountered:
Complete Description of Issue
This code no longer produces validation failures after upgrading to 2.3
Steps to reproduce
Gemfile
repro.rb
Expected behavior
The input parameters should be invalid.
Actual behavior
The errors added are lost somewhere and the form is marked as valid.
System configuration
Reform version: Upgrading from 2.2.4 to 2.3.1
Reform-Rails version: Upgrading from 0.1 to 0.2
The text was updated successfully, but these errors were encountered: