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

Inherits:
Aws::Templates::Utils::Parametrized::Constraint show all
Defined in:
lib/aws/templates/utils/parametrized/constraints.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, #to_proc

Constructor Details

#initialize(rex) ⇒ Matches

Returns a new instance of Matches.



258
259
260
# File 'lib/aws/templates/utils/parametrized/constraints.rb', line 258

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

Instance Attribute Details

#expressionObject (readonly)

Returns the value of attribute expression.



256
257
258
# File 'lib/aws/templates/utils/parametrized/constraints.rb', line 256

def expression
  @expression
end