Skip to content

Async Email Validation #58

@Seth10001

Description

@Seth10001

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>
        );
    }}
    />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions