-
Added a
fill
field option to specify how to fill a field. For example:class ExampleForm < Formeze::Form field :year, required: false, fill: ->{ _1.date&.year } end
-
Added functionality for defining field specific error messages via i18n.
Add translations to your locale files like this:
ExampleForm: errors: comments: required: 'are required'
-
Removed support for older rubies. Required ruby version is now 3.0.0
-
Changed from cgi to rack for parsing form data, adding support for parsing requests with different methods e.g. PUT and PATCH instead of just POST.
Whilst this should largely be backwards compatible there are some differences, for example uploaded files will be instances of
Rack::Multipart::UploadedFile
instead ofStringIO
instances as they were before. -
Changed the default blank value to
nil
-
Added dependency on cgi gem
-
Added support for lambda conditions without arguments
-
Fixed custom validation for fields with multiple values
- Fixed regression in v4.2.0 when mime-types gem is not loaded
-
Fixed file validation for e.g.
.md
files sent as application/octet-stream -
Fixed file validation for e.g.
.rtf
files sent as text/rtf
- Fixed compatibility with rack 3+
- Fixed outdated changelog_uri
-
Removed support for older rubies. Required ruby version is now 2.4.0
-
Changed the code to use keyword arguments for options
-
Renamed the
when
validation option toif
-
Added
'commit'
to the list of Rails form keys to ignore (#4) -
Added frozen string literal comment
-
Extracted private constants to reduce memory allocations
-
Removed spec file from gem
-
Added functionality for handling multipart form data. For example:
class ExampleForm < Formeze::Form field :image, accept: 'image/jpg,image/png', maxsize: 1000 end
For this to work the request needs to be passed to the parse method:
ExampleForm.new.parse(request)
-
Removed the deprecated parse class method
-
Removed Ruby 1.8.7 compatibility
-
The #fill and #parse instance methods now return self. So instead of this:
form = ExampleForm.new form.parse(request.raw_post)
You can now do this:
form = ExampleForm.new.parse(request.raw_post)
-
Deprecated the parse class method
- Fixed that custom validation should not execute for optional fields with blank values
-
Fixed that custom validation should only execute when there are no existing errors on the associated field
-
Removed
:word_limit
field option
-
Added new custom validation functionality
-
Removed existing (undocumented) custom validation functionality
-
KeyError now includes an error message when raised for unexpected keys
-
Added #to_h form instance method
-
Removed
:char_limit
field option -
Deprecated
:word_limit
field option (use custom validation instead)
-
Added
:minlength
field option -
Added
:maxlength
field option -
Deprecated
:char_limit
field option (use:maxlength
instead)
- Added
:blank
field option for specifying a null object to be used in place of blank input
-
Added #fill instance method
-
Improved handling of Rails utf8/authenticity_token parameters
-
Ruby 1.8.7 compatibility
-
Renamed
Formeze::UserError
toFormeze::ValidationError
-
Added #to_hash instance method
-
Added #errors_on? instance method for checking if there are errors on a specific field
-
Added #errors_on instance method for accessing the errors on a specific field
-
Added parse class method, so instead of this:
form = ExampleForm.new form.parse(request.raw_post)
You can now do this:
form = ExampleForm.parse(request.raw_post)
-
Added
Formeze::Form
class, so forms can now be defined like this:class ExampleForm < Formeze::Form end
The previous style of setup is still supported:
class ExampleForm < SomeAncestorClass Formeze.setup(self) end
-
Added #errors? instance method
-
Added
Formeze.scrub
method so that the scrub methods can be re-used outside field validation
- Added
:scrub
field option for cleaning up input data before validation
-
Added functionality for overriding error messages via i18n
-
Added functionality for setting field labels globally via i18n
- Replaced experimental guard/halting functionality with
:defined_if
and:defined_unless
field options
- Fixed early return from guard/halting conditions
- Fixed validation so that additional checks are skipped if the input is blank
- Added an error message for
Formeze::KeyError
exceptions
- Changed behaviour of experimental guard conditions and added halting conditions with opposite behaviour
- First version!