IsRequiredValidator is not defined


#1

Hello,

I am trying to validate input using the tools provided in the framework. I a using the code provided under the “validation” section as a guide: https://www.jovo.tech/docs/routing/input. However, I keep getting an IsRequiredValidator is not defined error. Syntactically my code and the example are exactly the same. I am not sure what the problem is. I am not sure where or how to define IsRequiredValidator. Any thoughts?

Thanks for your time!


#2

Hi @Amir_Ansari, this feature is not fully released yet, so the documentation may need some tweaks. For now, you have to import the validator with const { IsRequiredValidator } = require('jovo-core');.


#3

I really appreciate it! Super helpful. I hope you don’t mind if I bother you a little more.

I am using the validation feature to prompt and require the user to give me all the inputs I need. However after the user is successfully prompted, I get a no route error: ERR_NO_ROUTE. I am assuming this is the case because the user input that is meant to be clarification is being handled like an entirely new intent.

Am I just not using this functionality correctly?


Using the validation feature to require input
#4

No problem :slight_smile: I’m not sure about the error. Could you please show some code snippets of how you handle the validation?


#5

const schema = {
date: new IsRequiredValidator(),
time: new IsRequiredValidator(),
duration: new IsRequiredValidator()
};

    const validation = this.validate(schema);

    if(validation.failed('date')) 
    {
        return this.ask('Please tell me what day you want to reserve the room?');
    }

    if (validation.failed('time')) 
    {
        return this.ask("Please tell me when you want to reserve the room?"); 
    }

    if (validation.failed('duration')) 
    {
        return this.ask("Please tell me for how long you want to reserve the room?"); 
    }

#6

It seems like your input matches an intent that your handler cannot process. This is usually the result of an incoming intent that is not listed in your handler and the lack of a global Unhandled Intent. Please create a global Unhandled Intent in your handler and run console.log(this.$request.getIntentName()); in there. This will give you the incoming intent name that the Handler is trying to process.