Is there any way to validate input data that we are manually filling in the input fields like email, phone number or ip address on the form

Here what i want is that an error message should be displayed that email is not valid when executing the node.
Is there any way to add regex or something.

Version 0.222.2

Thanks

Hi @Bhawesh_Kumar - welcome to the community :cake:

You could use an If node with regex to check for valid emails. I’ve set up an example workflow here, with emails redacted - but I just tested and it worked with both a valid email (and successfully caught and didn’t fire off for invalid ones).

Let me know if that helps!

1 Like

Hi @EmeraldHerald,

I have created my own custom node as posted in the question and as we can provide validation for required field,I want to show wrong email validation like the above. So is there any way to accomplish this because I need to call an api on executing my node so need to do validations on the form itself so the user will be notified about the wrong data.

Or please suggest an appropriate way to accomplish this task.

As this is not my final node but I will add more operations in this node so I have no idea about the fields I am going to have so just checking what functionalities are provided on the fields.

Thanks

@Bhawesh_Kumar If you are developing a custom node and want to validate the email node parameter, you can do so in the execute function and throw a NodeOperationError (see gmail node example). This would validate the email on execution and return an error message.

GenericFunctions.ts

throw new NodeOperationError(this.getNode(), 'Invalid email address', {

To be clear this won’t add validation while someone is typing an email into the node parameter, but it would throw an error on execution.

That should help!

1 Like

Thanks a lot @EmeraldHerald for fast response. It worked.

1 Like

You might also like this

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.