Class: Compel::Builder::String

Inherits:
Schema
  • Object
show all
Includes:
CommonValue
Defined in:
lib/compel/builder/string.rb

Instance Attribute Summary

Attributes inherited from Schema

#options, #type

Instance Method Summary collapse

Methods included from CommonValue

#in, #is, #max, #min, #range

Methods inherited from Schema

#default_value, #required?, #validate

Methods included from Common

#default, #length, #required

Constructor Details

#initializeString

Returns a new instance of String.



8
9
10
# File 'lib/compel/builder/string.rb', line 8

def initialize
  super(Coercion::String)
end

Instance Method Details

#format(regex) ⇒ Object



12
13
14
15
# File 'lib/compel/builder/string.rb', line 12

def format(regex)
  options[:format] = Coercion.coerce!(regex, ::Regexp)
  self
end

#max_length(value) ⇒ Object



22
23
24
25
# File 'lib/compel/builder/string.rb', line 22

def max_length(value)
  options[:max_length] = Coercion.coerce!(value, ::Integer)
  self
end

#min_length(value) ⇒ Object



17
18
19
20
# File 'lib/compel/builder/string.rb', line 17

def min_length(value)
  options[:min_length] = Coercion.coerce!(value, ::Integer)
  self
end