1

enter image description here

I have to validate the incoming json payload and throw custom errors if the json is not valid. I tried implementing the validator interface as shown in the above image. But how should I access the payload now?In earlier versions the method accepted a mule event through which we could easily get the payload:

public interface Validator
{

    /**
     * Performs the validation and generates a
     * {@link ValidationResult} back.
     *
     * @param event the current {@link MuleEvent}
     * @return a {@link ValidationResult}
     */
    ValidationResult validate(MuleEvent event);
}
HMT
  • 2,093
  • 1
  • 19
  • 51
  • I do not believe that interface is meant to be implemented by users. You should just create your own custom SDK module https://docs.mulesoft.com/mule-sdk/1.1/getting-started – afelisatti Dec 30 '19 at 12:32
  • @afelisatti But I need custom validations with custom error messages. – HMT Dec 30 '19 at 21:00
  • A validator is just an operation that fails if it does not like the input and does nothing if it does. There's no actual need to use that interface. – afelisatti Jan 02 '20 at 22:16

0 Answers0