Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async Email Validation #58

Open
Seth10001 opened this issue Aug 25, 2020 · 1 comment
Open

Async Email Validation #58

Seth10001 opened this issue Aug 25, 2020 · 1 comment

Comments

@Seth10001
Copy link

Seth10001 commented Aug 25, 2020

I would like to validate an email's uniqueness asynchronously using an API call. If the validateEmail prop accepted promises then this could be done easily.

For example:

<ReactMultiEmail
    style={{ minHeight: '100px' }}
    emails={emails}
    onChange={(_emails: string[]) => {
        this.setState({ emails: _emails });
    }}
    validateEmail={async (email) => {
        let response = await axios.get('/api/valid-email', {  params: {  email: email }})
        //{.... data: {  valid: true } .... }
        return response.data.valid
    }}
    getLabel={(
        email: string,
        index: number,
        removeEmail: (index: number) => void,
    ) => {
        return (
        <div data-tag key={index}>
            {email}
            <span data-tag-handle onClick={() => removeEmail(index)}>
            ×
            </span>
        </div>
        );
    }}
    />
@jopemachine
Copy link
Contributor

I made a PR to support async-validate.

#59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants