Module: MediaTypes::Validation
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/media_types/validation.rb,
lib/media_types/validation/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.configure(&block) ⇒ Object
15 16 17 |
# File 'lib/media_types/validation.rb', line 15 def self.configure(&block) instance_exec self, &block end |
Instance Method Details
#validate_json_with_media_type(body, media_type:) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/media_types/validation.rb', line 19 def validate_json_with_media_type(body, media_type:) return body unless media_type_json?(media_type: media_type) if raise_on_json_invalid_media json_valid_media_or_throw?(body, media_type: media_type) else json_valid_media?(body, media_type: media_type) end end |