Hi all,
I am trying to validate a form containing six slots. Following this documentation, I have tried to validate one slot by:
actions:
- validate_standard_form
class ValidateStandardForm(FormValidationAction):
def name(self) -> Text:
return "validate_standard_form"
def validate_pizza_quantity(self,
slot_value: Any,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: DomainDict) -> Dict[Text, Any]:
flag = 0
for qty in slot_value:
if qty < 1:
flag = 1
dispatcher.utter_message("!!!Pizza can't be negative!!!")
if flag == 0:
return {"pizza_quantity": slot_value}
else:
return {"pizza_quantity": None}
unfortunately, this function doesn’t work, so the slot can still be filled with negatives values, why?
In the link above, I have also read that we can use tracker.slots_to_validate() for customizing the validation, but I can’t figure out how. Were I could find more documentation/examples about it?
Just to check, could you share your domain.yml file? You may have misspelled a slot/form name. You don’t need to share the whole file, but the parts about entities, slots and forms might help us figure that out. Looking at the action code, it seems fine.
Note that you can also add print statements to the code to help you debug. You can confirm the slot value that goes into the action is actually received.
Thanks @koaning
Without the validation action, the form works fine.
I have tried to print a message at the beginning of the action, but it’s not displayed
Hello @koaning , I have something similar but I have already checked the names and they match, could you please just have a look at my entires here and see if you notice something off please?
It sounds like there may be an issue with the code in your validation function. Check to make sure that the print/utter_message commands are properly formatted and being called in the correct section of the code. You may also want to double-check your indentation and syntax for any errors.