Email validator snippet for React Studio?

Has someone used an email validator snippet for React Studio and would like to share. I’d appreciate it if you could.

Thank you

I’ve come up with this:

	if (name == 'name') {
		if (value == '') {
			alert("Please enter your name.");
			return false;
		}
		else {
			return true;
		};
	}

	if (name == 'email') {
		const emailIsValid = name => {
			return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(name);
		}
		if (value == '') {
			alert("Please enter your email address.");
			return false;
		}
		else {
			if (!emailIsValid(value)) {
				alert("Please enter a valid email address.");
				return false;
			};
			return true;
		};
	}
return input;

I tried using a dataslot (instead of the alert) to put the error message in, but I cannot get that part to work:
this.props.appActions.updateDataSlot(‘ds_notification’, “Please enter your name.”);

Erwin

1 Like