lib/fakeit/validation/validator.rb in fakeit-0.7.1 vs lib/fakeit/validation/validator.rb in fakeit-0.8.0
- old
+ new
@@ -1,11 +1,9 @@
module Fakeit
module Validation
class Validator
- def initialize(operation)
- @operation = operation
- end
+ def initialize(operation) = @operation = operation
def validate(body: {}, params: {}, headers: {})
options = OpenAPIParser::SchemaValidator::Options.new(coerce_value: true)
validate_body(body) unless request_content_types.empty?
@@ -24,19 +22,13 @@
raise ValidationError, 'Invalid request content type' if body[:media_type]
raise ValidationError, 'Request body is required' if request_body.required
end
end
- def can_validate?(media_type)
- media_type =~ %r{^application/.*json} || media_type == 'multipart/form-data'
- end
+ def can_validate?(media_type) = media_type =~ %r{^application/.*json} || media_type == 'multipart/form-data'
- def request_content_types
- request_body&.content&.keys.to_a
- end
+ def request_content_types = request_body&.content&.keys.to_a
- def request_body
- @operation.operation_object.request_body
- end
+ def request_body = @operation.operation_object.request_body
end
end
end