Method: Rentlinx::AttributeProcessor#process
- Defined in:
- lib/rentlinx/validators/attribute_processor_service.rb
#process ⇒ Object
Processes the attributes, both validating them and processing them into a format suitable for Rentlinx.
This method also populates the errors attribute, so it must be run before calling .valid? or querying for errors.
Currently, phone number, state, zip, and leads URL are validated. They are passed into their own validator objects: PhoneValidator, StateValidator, ZipValidator, and UrlValidator
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rentlinx/validators/attribute_processor_service.rb', line 35 def process validators = { phoneNumber: PhoneValidator, state: StateValidator, zip: ZipValidator, leadsURL: UrlValidator, city: CityValidator, address: AddressValidator, capAmount: AmountValidator, companyCapAmount: AmountValidator } @attrs.each do |field, val| next unless validators.keys.include?(field) validator = validators[field].new(val) @processed_attrs[field] = validator.processed_value @errors[field] = validator.error unless validator.valid? end @processed_attrs end |