Sha256: 830e94c1b94ae00c4d8c4d362aca6930e01d3a06ee71623f2a2210154cb5ff72
Contents?: true
Size: 660 Bytes
Versions: 1
Compression:
Stored size: 660 Bytes
Contents
require 'snils' # SNILS validation for Active Model (Active Record and Ruby on Rails) # # Usage: # # 1. Modify your gemfile to require 'snils/rails' # # gem 'snils', require: 'snils/rails' # # 2. Add +:snils+ validation to SNILS attributes # # validates :snils, presence: true, uniqueness: true, snils: true # class SnilsValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) snils = Snils.new(value) if snils.errors.any? && options[:message] record.errors.add(attribute, options[:message]) else snils.errors.each do |error| record.errors.add(attribute, *error) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
snils-0.2.0 | lib/snils/rails.rb |