Sha256: 44b4b71c032f50123a8104834782ae5913d21338c32dfc49eaa65cfa00484f27

Contents?: true

Size: 748 Bytes

Versions: 1

Compression:

Stored size: 748 Bytes

Contents

# frozen_string_literal: true

# /customers/phone_verifications
module Phone
  class VerificationForm < ApplicationForm
    attribute :phone_code,   String
    attribute :phone_area,   String
    attribute :phone_number, String

    validates :phone_code, presence: true, numericality: true, length: { minimum: 1, maximum: 10 }
    validates :phone_area, numericality: true, length: { maximum: 6 }, allow_blank: true
    validates :phone_number, presence: true, numericality: true, length: { minimum: 6, maximum: 12 }

    def submit
      return false unless valid?

      api_answer = TranslationCms::Api::Customers::PhoneVerifications.create(phone_verification: attributes)
      merge_responce! api_answer
      errors.empty?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/forms/phone/verification_form.rb