Sha256: e384ee11888b7af9968609a5bcf83e9ec85d38aa2dab680c24f43cdf57e69080

Contents?: true

Size: 380 Bytes

Versions: 4

Compression:

Stored size: 380 Bytes

Contents

# frozen_string_literal: true

require 'zoho_hub/validations/base_validation'

module ZohoHub
  module Validations
    class ValidateLength < BaseValidation
      def validate(options = {})
        value = record.send(field)

        return unless value

        return if value.size <= options[:length]

        record.add_error(field, 'is too long')
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zoho_hub-0.4.2 lib/zoho_hub/validations/validate_length.rb
zoho_hub-0.4.1 lib/zoho_hub/validations/validate_length.rb
zoho_hub-0.4.0 lib/zoho_hub/validations/validate_length.rb
zoho_hub-0.3.0 lib/zoho_hub/validations/validate_length.rb