sssaha143
(Subhajit Saha)
1
FormValidationAction validation is not working.
Action.py
class ValidatePerchaseRequisitionForm(FormValidationAction):
def name(self) -> Text:
return "Validate_PurchaseReq_view_form"
def validate_PR_number(
self,
slot_value: Any,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if value.isdigit() and len(value) == 6:
print(value)
return {"PR_number": value}
else:
dispatcher.utter_template(text="Please enter valid User ID!")
return {"PR_number": None}
domail.yml
actions:
- Validate_PurchaseReq_view_form
Please review my code. I am not getting any solution. and explain also.
thank you
m.vielkind
(Matthew Vielkind)
2
Hi @sssaha143
can you show your form definition as well?
sssaha143
(Subhajit Saha)
3
hi @m.vielkind . Please help me out
forms:
PurchaseReq_view_form:
PR_number:
- type: from_entity
entity: PR_number
rule.yml
- rule: Activate View form
steps:
- intent: PurchaseReq_view
- action: PurchaseReq_view_form
- active_loop: PurchaseReq_view_form
- rule: Submit View form
condition:
- active_loop: PurchaseReq_view_form
steps:
- action: PurchaseReq_view_form
- active_loop: null
- action: action_hello_world
- action: action_chat_restart
m.vielkind
(Matthew Vielkind)
4
Can you try making two adjustments. Can you try changing your form to:
forms:
PurchaseReq_view_form:
PR_number:
- type: from_entity
entity: PR_number
- type: from_text
And then in your validation action there looks like there is one too many arguments:
def validate_PR_number(
self,
slot_value: Any,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
Finally, change the name of the validate action to be lowercase:
def name(self) -> Text:
return "validate_PurchaseReq_view_form"
Let me know if this helps.