Sha256: 3349c899ea893b9ee0813c7bef15cf1bbab7668f328b3a6e647f275bbb7bfcc1
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true require 'dry-validation' module Fawry module Contracts class CreateCardTokenRequestContract < Dry::Validation::Contract params do required(:customer_profile_id).value(:string) required(:customer_mobile).value(:string) required(:merchant_code).value(:string) required(:customer_email).value(:string) required(:card_number).value(:string) required(:expiry_year).value(:string) required(:expiry_month).value(:string) required(:cvv).value(:string) end rule(:customer_email) do unless /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i.match?(value) key? && key.failure('has invalid format') end end rule(:merchant_code) do if Fawry.configuration.fawry_merchant_code.nil? && ENV['FAWRY_MERCHANT_CODE'].nil? && value.nil? key(:merchant_code).failure('fawry merchant code is required in either Fawry.configuration or'\ 'as an environment variable (FAWRY_MERCHANT_CODE), or as an argument to this method') end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fawry-1.3.1 | lib/fawry/contracts/create_card_token_request_contract.rb |
fawry-1.3.0 | lib/fawry/contracts/create_card_token_request_contract.rb |