Sha256: c6c2046a0974f6d6da60b4d676bc71857a4c2cec0ff4f6acf100881694dff2b1
Contents?: true
Size: 932 Bytes
Versions: 26
Compression:
Stored size: 932 Bytes
Contents
module Foobara module BuiltinTypes module String module SupportedValidators class Matches < TypeDeclarations::Validator class DoesNotMatchError < Foobara::Value::DataError class << self def context_type_declaration { value: :string, regex: :duck # TODO: make a regex type?? } end end end def regex declaration_data end def validation_errors(string) if string !~ regex build_error(string) end end def error_message(value) "#{value.inspect} did not match #{regex.inspect}" end def error_context(value) { value:, regex: regex.to_s } end end end end end end
Version data entries
26 entries across 26 versions & 1 rubygems