Class: GuardrailsRuby::Checks::Format

Inherits:
GuardrailsRuby::Check show all
Defined in:
lib/guardrails_ruby/checks/format.rb

Instance Attribute Summary

Attributes inherited from GuardrailsRuby::Check

#options

Instance Method Summary collapse

Methods inherited from GuardrailsRuby::Check

check_name, direction, #initialize, lookup

Constructor Details

This class inherits a constructor from GuardrailsRuby::Check

Instance Method Details

#call(text, context: {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/guardrails_ruby/checks/format.rb', line 11

def call(text, context: {})
  schema = @options.fetch(:schema, {})
  type = schema[:type]&.to_sym

  case type
  when :json
    validate_json(text)
  when :markdown
    pass! # basic acceptance for now
  else
    pass!
  end
end