Sha256: a6dba45e02d8aff32bd9da849c98920ca46bbf8d703054177aaa9ff33b7241c2
Contents?: true
Size: 512 Bytes
Versions: 1
Compression:
Stored size: 512 Bytes
Contents
# frozen_string_literal: true class AlphaValidator < BaseValidator CASES = { lower: "a-z", upper: "A-Z", any: "A-Za-z" }.freeze def validate_each(record, attribute, value) assert_valid_case! super end private def assert_valid_case! assert_valid_option!(:case, CASES.keys, option: kase) end def kase options[:case] || :any end def regexp /^[#{CASES[kase]}#{' ' if options[:allow_space]}]+$/ end def valid_regexp? value.to_s =~ regexp end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lite-validators-1.8.0 | lib/lite/validators/alpha_validator.rb |