Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleSearchInput(searchTerm) {
this.props.setSearchTerm(searchTerm);
// Consumer org can only search via email
if (this.props.isConsumerOrg && isEmail(searchTerm) || !this.props.isConsumerOrg && searchTerm.length >= 3) {
this.doSearch(searchTerm);
}
}
validateForm() {
if (!this.validateString(this.state.name))
throw new Error('Please enter your name.');
if (!isEmail(this.state.email))
throw new Error('Please enter a valid e-mail address.');
if (!this.validateString(this.state.message))
throw new Error('Please enter a message.');
}
handleSubmit = () => {
const errors = [];
const { email, password } = this.state;
if (!isEmail(email)) {
errors.push('Please enter your e-mail');
}
if (!password || password.length < 6) {
errors.push('Your password must be at least 6 characters');
}
this.setState({ errors });
if (!errors.length) {
this.props.login(email, password).then(() => {
if (this.props.error) {
this.setState({ errors: [this.props.error] });
}
});
}
const handleSubmit = useCallback(() => {
const cleanData = {
...data,
email: data.email.trim(),
name: data.name.trim(),
};
if (!isEmail(cleanData.email)) {
emailField.current.select();
return;
}
if (!cleanData.password) {
passwordField.current.focus();
return;
}
if (!cleanData.name) {
nameField.current.select();
return;
}
onCreate(cleanData);
}, [onCreate, data]);
const getEmailState = (value, shouldValidate) => ({
value,
error:
(value.trim().length <= 0 && t('Trial/Form/email/error/empty')) ||
(!isEmail(value) && t('Trial/Form/email/error/invalid')),
dirty: shouldValidate
})
const [email, setEmail] = useState(
export const email = value => {
if (value && isEmail(value)) return undefined
return 'Invalid email'
}
handleEmail(value, shouldValidate, t) {
this.setState(
FieldSet.utils.mergeField({
field: 'email',
value,
error:
(value.trim().length <= 0 && t('pledge/contact/email/error/empty')) ||
(!isEmail(value) && t('pledge/contact/email/error/invalid')),
dirty: shouldValidate
})
)
}
handleVoucherCode(value, shouldValidate, t) {
handleSubmitLoginAction(e) {
e.preventDefault();
if (isEmail(this.state.email) && this.state.password.length > 7) {
const { email, password } = this.state;
this.props.fetchLoginIfNeeded(email, password);
} else {
this.setState({
...this.state,
isValidEmail: false,
isValidPassword: false,
errorMessage: 'Email or Password is not valid'
});
}
}
render() {
export const isValidEmail = value => (value && !isEmail(value)
? 'Invalid email address!'
: undefined);