Sha256: ae59ba76a36db7ae467e355ba7bab9e42fd07b824669b7d644ae23f59cda9e3c
Contents?: true
Size: 800 Bytes
Versions: 2
Compression:
Stored size: 800 Bytes
Contents
# encoding: utf-8 # frozen_string_literal: true module Mixture module Validate # Checks that a value matches. class Match < Base register_as :match register_as :format # Performs the validation. # # @param (see Base#validate) # @return (see Base#validate) # @raise [ValidationError] If {#match?} returns false. def validate(record, attribute, value) super error("Value does not match") unless match? end private # Checks if the value matches the given matcher. It uses the # `=~` operator. If it fails (i.e. raises an error), it returns # false. # # @return [Boolean] def match? @value =~ @options rescue StandardError false end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mixture-0.7.1 | lib/mixture/validate/match.rb |
mixture-0.7.0 | lib/mixture/validate/match.rb |