Class: Aws::Templates::Utils::Parametrized::Constraint::Matches

Inherits:
Aws::Templates::Utils::Parametrized::Constraint show all
Defined in:
lib/aws/templates/utils/parametrized/constraint/matches.rb

Overview

Check if value matches the regular expression

Checks if value matches the regular expression. If value doesn’t match, an exception will be thrown with attached description of regular expression and value converted to string.

Example

class Piece
  include Aws::Templates::Utils::Parametrized
  parameter :param1, constraint: matches('A+')
end

i = Piece.new(:param1 => 'Ask')
i.param1 # => 'Ask'
i = Piece.new(:param1 => 'Bar')
i.param1 # raise ParameterValueInvalid

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Aws::Templates::Utils::Parametrized::Constraint

#check_wrapper, #if, #pre_condition, #to_proc

Constructor Details

#initialize(rex) ⇒ Matches

Returns a new instance of Matches.



29
30
31
# File 'lib/aws/templates/utils/parametrized/constraint/matches.rb', line 29

def initialize(rex)
  @expression = Regexp.new(rex)
end

Instance Attribute Details

#expressionObject (readonly)

Returns the value of attribute expression.



27
28
29
# File 'lib/aws/templates/utils/parametrized/constraint/matches.rb', line 27

def expression
  @expression
end