Sha256: 0c7cff995edb41d4e3ba9217760fcaf6590893514fdffa3acd2bd69248ceb737

Contents?: true

Size: 796 Bytes

Versions: 1

Compression:

Stored size: 796 Bytes

Contents

# This is the generic validator class that it will be the dad of all specific validation classes.
module Owasp
  module Esapi
    module Validator
      class GenericValidator
        
        attr_accessor :matcher
        
        # Creates a new generic validator.
        # @param [String] matcher the regular expression to be matched from this validator
        def initialize(matcher)
          @matcher = matcher
        end
        
        # Validate a string against the matcher
        # @param [String] string the string that need to be validated
        # @return [Boolean] true if the string matches the regular expression, false otherwise
        def valid?(string)
          r = Regexp.new(@matcher)
          
          !(string =~ r).nil?
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
owasp-esapi-ruby-0.30.0 lib/validator/generic_validator.rb