Skip to content

Commit

Permalink
remove double "if" condition
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba-kubula committed Mar 20, 2015
1 parent a21faf5 commit f5878ec
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/mixins/validatable-http-message.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -159,28 +159,27 @@ class Validatable
@validation.body.expectedType = null
@validation.body.results ?= []

if @expected.bodySchema? and
@expected.bodySchema?
if typeof @expected.bodySchema == 'string'
try
parsed = JSON.parse @expected.bodySchema
if typeof parsed != 'object' or Array.isArray parsed
message = {
message: 'Expected body: JSON Schema provided, but it is not an Object'
severity: 'error'
}
@validation.body.results.push message
else
@validation.body.expectedType = 'application/schema+json'
catch error
if @expected.bodySchema?
if typeof @expected.bodySchema == 'string'
try
parsed = JSON.parse @expected.bodySchema
if typeof parsed != 'object' or Array.isArray parsed
message = {
message: 'Expected body: JSON Schema provided, but it is not a parseable JSON'
message: 'Expected body: JSON Schema provided, but it is not an Object'
severity: 'error'
}
@validation.body.results.push message
return
else
@validation.body.expectedType = 'application/schema+json'
else
@validation.body.expectedType = 'application/schema+json'
catch error
message = {
message: 'Expected body: JSON Schema provided, but it is not a parseable JSON'
severity: 'error'
}
@validation.body.results.push message
return
else
@validation.body.expectedType = 'application/schema+json'
else

expectedContentType = @expected.headers?['content-type']
Expand Down

0 comments on commit f5878ec

Please sign in to comment.