Sha256: 588338943ed06e73986632e28d30afc4bde57a0511d6c503a5a63ccfa04d4233
Contents?: true
Size: 825 Bytes
Versions: 2
Compression:
Stored size: 825 Bytes
Contents
module Compel module Builder class String < Schema # Taken from ruby_regex gem by @eparreno # https://github.com/eparreno/ruby_regex URL_REGEX = /(\A\z)|(\A(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?\z)/ix # Taken from Michael Hartl's 'The Ruby on Rails Tutorial' # https://www.railstutorial.org/book EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i include CommonValue def initialize super(Coercion::String) end def format(regex) options[:format] = Coercion.coerce!(regex, Coercion::Regexp) self end def url options[:format] = URL_REGEX self end def email options[:format] = EMAIL_REGEX self end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
compel-0.4.0 | lib/compel/builder/string.rb |
compel-0.3.7 | lib/compel/builder/string.rb |