Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A repository dedicated to a ruby gem that enables ruby classes to skip desired validations, because rails only enables to skip all validations or none of them by default.

License

Notifications You must be signed in to change notification settings

Victorcorcos/validations-skipper

Repository files navigation

Validations Skipper Logo

A repository dedicated to a ruby gem that allows classes to skip desired validations.

Why it is necessary?

Currently, the rails only enables to skip all validations via:

item.save!(validate: false)

However, sometimes what you want is just to skip one or another validation, not all of them.

With this gem, you can easily skip the validations that you want.

Instalation

Add validations-skipper to your Gemfile.

gem 'validations-skipper'

Usage

  1. First it is required to include the ValidationsSkipable module on the class you want to enable this feature.
require 'validations_skipper'
class ClassExample
 include ActiveModel::Validations # this is not necessary if this class is a descendent of an ActiveRecord::Base
 include ValidationsSkipable
 
 validate :validation_method
 def validation_method
 errors.add(:column, 'An error message')
 end
end
  1. Then you just need to assign the desired methods you want to skip on the new skip_validations attribute.
object = ClassExample.new
object.skip_validations = [:validation_method]
object.save! # Here you can see the object is saved and the validation method is skipped

Contact


*This repository is maintained and developed by Victor Cordeiro Costa. For inquiries, partnerships, or support, don't hesitate to get in touch.

About

A repository dedicated to a ruby gem that enables ruby classes to skip desired validations, because rails only enables to skip all validations or none of them by default.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

Languages

AltStyle によって変換されたページ (->オリジナル) /