Sha256: 433aab3853fef03f2c8e9220492b91f7143ccc4fc07ad5e0aee560def8ce0985

Contents?: true

Size: 996 Bytes

Versions: 2

Compression:

Stored size: 996 Bytes

Contents

module VCardio
  module Validator
    #
    # Name definition:
    #   "SOURCE" / "KIND" / "FN" / "N" / "NICKNAME"
    #   / "PHOTO" / "BDAY" / "ANNIVERSARY" / "GENDER" / "ADR" / "TEL"
    #   / "EMAIL" / "IMPP" / "LANG" / "TZ" / "GEO" / "TITLE" / "ROLE"
    #   / "LOGO" / "ORG" / "MEMBER" / "RELATED" / "CATEGORIES"
    #   / "NOTE" / "PRODID" / "REV" / "SOUND" / "UID" / "CLIENTPIDMAP"
    #   / "URL" / "KEY" / "FBURL" / "CALADRURI" / "CALURI" / "XML"
    #   / iana-token / x-name
    #
    # Although the name definition has a long list of possible values the
    # `iana-token` pattern is the least common denominator. It basically allows
    # `name` to match anything that follows the `1*(ALPHA / DIGIT / "-")`
    # pattern. Therefore that's all we validate against.
    #
    # @private
    #
    class NameValidator
      def self.call(name)
        if /\A[A-Za-z\d-]*\z/.match(name).nil?
          fail VCardio::Error, "Invalid name: #{name}"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vcardio-0.1.1 lib/vcardio/validator/name_validator.rb
vcardio-0.1.0 lib/vcardio/validator/name_validator.rb