Sha256: 382c8a06e9ea7221b19a2017ac01374e1aab92415cfb583c54768e10de4f1185

Contents?: true

Size: 526 Bytes

Versions: 4

Compression:

Stored size: 526 Bytes

Contents

I18n.load_path += Dir.glob( File.expand_path('../locales/*.{rb,yml}', __FILE__) )

class PhoneValidator < ActiveModel::EachValidator
  def validate_each(object, attribute, value)
    object.errors.add(attribute, :invalid_phone_number) unless Phonie::Phone.valid?(value)
  end
end

class MobilePhoneValidator < ActiveModel::EachValidator
  def validate_each(object, attribute, value)
    object.errors.add(attribute, :invalid_mobile_phone_number) unless Phonie::Phone.valid?(value) && Phonie::Phone.is_mobile?(value)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
phonie-3.3.1 lib/phonie/railties/validator.rb
phonie-3.2.2 lib/phonie/railties/validator.rb
phonie-3.2.1 lib/phonie/railties/validator.rb
phonie-3.2.0 lib/phonie/railties/validator.rb