在Mulesoft中使用“验证JSON模式”元素时,如果发生多个验证错误,则会将以下消息放入#[exception]。
org.mule.api.MessagingException: Json content is not compliant with schema
com.github.fge.jsonschema.core.report.ListProcessingReport: failure
--- BEGIN MESSAGES ---
error: string "blah" is too long (length: 4, maximum allowed: 3)
level: "error"
schema: {"loadingURI":"file:/...}
instance: {"pointer":"/blah_blah_code"}
domain: "validation"
keyword: "maxLength"
value: "blah"
found: 4
maxLength: 3
error: string "USDe" is too long (length: 4, maximum allowed: 3)
level: "error"
schema: {"loadingURI":"file:/..."}
instance: {"pointer":"/blah_code"}
domain: "validation"
keyword: "maxLength"
value: "USDe"
found: 4
maxLength: 3
--- END MESSAGES ---
有没有提取个别错误?
答案 0 :(得分:0)
您可以在catch-exception-strategy中使用when condition并相应地为每个元素设置有效负载
下面是blah元素的例子
<when expression="#[exception.causedBy(org.mule.api.MessagingException)&& exception.cause.message.contains('schema') && exception.cause.message.contains('blah')]">
<set-payload value="include element specification here" doc:name="Json schema validation error"/>
</when>