lib/pacto/validators/request_body_validator.rb in pacto-0.3.0 vs lib/pacto/validators/request_body_validator.rb in pacto-0.3.1
- old
+ new
@@ -7,14 +7,17 @@
def self.section_name
'request'
end
+ def self.subschema(contract)
+ contract.request.schema
+ end
+
def call(env)
if env[:validation_results].empty? # skip body validation if we already have other errors
- expected_body = env[:contract].request.schema
actual_body = env[:actual_request]
- errors = self.class.validate(expected_body, actual_body)
+ errors = self.class.validate(env[:contract], actual_body)
env[:validation_results].concat errors.compact
end
@app.call env
end
end