lib/volt/models/validators/phone_number_validator.rb in volt-0.8.27.beta3 vs lib/volt/models/validators/phone_number_validator.rb in volt-0.8.27.beta4

- old
+ new

@@ -1,19 +1,14 @@ module Volt - class PhoneNumberValidator + class PhoneNumberValidator < FormatValidator DEFAULT_OPTIONS = { with: /^(\+?\d{1,2}[\.\-\ ]?\d{3}|\(\d{3}\)|\d{3})[\.\-\ ]?\d{3,4}[\.\-\ ]?\d{4}$/, message: 'must be a phone number with area or country code' } - def self.validate(model, old_model, field_name, options) - new(model, field_name, options).errors - end + private - def self.new(model, field_name, options) - options = DEFAULT_OPTIONS if options == true - options = DEFAULT_OPTIONS.merge options - - FormatValidator.new(model, field_name).apply options + def default_options + DEFAULT_OPTIONS end end end