Sha256: f4a3d98c0813516a4df4d2e7eff707569640747f0010f3ce8a81285f6f4d2e12
Contents?: true
Size: 1.21 KB
Versions: 3
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true require_relative 'field_validator' module Dragnet module Validators module Fields # Validates the ID Field for Manual Test Records class IDValidator < Dragnet::Validators::Fields::FieldValidator # Validates the Requirement ID(s) of the MTR # @param [String] key The name of the key # @param [Object] value The value of the key # @raise [Dragnet::Errors::ValidationError] If the Requirement ID(s) are # missing, they are not a String or an Array of Strings if they contain # a disallowed character or (in the case of an Array) any of its # elements is not a String. def validate(key, value) validate_presence(key, value) validate_type(key, value, String, Array) if value.is_a?(String) match = value.match(/,|\s/) return unless match validation_error( "Disallowed character '#{match}' found in the value for key #{key}. "\ 'To use multiple requirement IDs please put them into an array' ) else validate_array_types(key, value, String) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dragnet-5.3.1 | lib/dragnet/validators/fields/id_validator.rb |
dragnet-5.3.0 | lib/dragnet/validators/fields/id_validator.rb |
dragnet-5.2.1 | lib/dragnet/validators/fields/id_validator.rb |