Low commit activity in last 3 years
No release in over a year
validations-skipper is a gem that enables objects to skip specified validations with ease. It can be applied to ActiveRecord::Base classes.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.10
~> 12.1

Runtime

 Project Readme

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.