Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/polish_validators_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@
class IbanValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
validator = ::PolishValidators::IbanValidator.new(value)
record.errors.add(attribute, @options[:message] || 'Invalid IBAN format') unless validator.valid?
record.errors.add(attribute, :invalid, **options) unless validator.valid?
end
end

class NipValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
validator = ::PolishValidators::NipValidator.new(value)
record.errors.add(attribute, @options[:message] || 'Invalid NIP format') unless validator.valid?
record.errors.add(attribute, :invalid, **options) unless validator.valid?
end
end

class PeselValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
validator = ::PolishValidators::PeselValidator.new(value)
record.errors.add(attribute, @options[:message] || 'Invalid PESEL format') unless validator.valid?
record.errors.add(attribute, :invalid, **options) unless validator.valid?
end
end

class RegonValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
validator = ::PolishValidators::RegonValidator.new(value)
record.errors.add(attribute, @options[:message] || 'Invalid REGON format') unless validator.valid?
record.errors.add(attribute, :invalid, **options) unless validator.valid?
end
end
2 changes: 1 addition & 1 deletion polish_validators_rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |spec|

spec.add_runtime_dependency 'polish_validators', '>= 1.0.1'
spec.add_runtime_dependency 'activerecord', '>= 4.0'
spec.add_development_dependency "bundler", "~> 1.7"
spec.add_development_dependency "bundler", ">= 1.7"
spec.add_development_dependency "rake", "~> 11.3.0"
spec.add_development_dependency "rspec", "~> 3.5.0"
end