How to use the validator/lib/isEmail function in validator

To help you get started, we’ve selected a few validator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webex / react-widgets / packages / node_modules / @ciscospark / widget-roster / src / container.js View on Github external
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);
    }
  }
github salomonelli / personal-portfolio / src / components / contact / contact.jsx View on Github external
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.');
    }
github ethibox / ethibox / src / client / js / login / Login.js View on Github external
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] });
                }
            });
        }
github meltyshev / planka / client / src / components / AddUserPopup / AddUserPopup.jsx View on Github external
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]);
github orbiting / republik-frontend / components / Card / Claim.js View on Github external
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(
github bpetetot / conference-hall / src / components / form / validators.js View on Github external
export const email = value => {
  if (value && isEmail(value)) return undefined
  return 'Invalid email'
}
github orbiting / republik-frontend / components / Account / Memberships / Claim.js View on Github external
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) {
github containerum / ui / src / containers / Login / index.js View on Github external
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() {
github iverenshaguy / book-a-meal / client / src / helpers / validations / validationTypes.js View on Github external
export const isValidEmail = value => (value && !isEmail(value)
  ? 'Invalid email address!'
  : undefined);