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

add validation meta #264

Merged
merged 4 commits into from
Feb 25, 2019
Merged

add validation meta #264

merged 4 commits into from
Feb 25, 2019

Conversation

nicknisi
Copy link
Member

@nicknisi nicknisi commented Feb 20, 2019

Type: feature

The following has been addressed in the PR:

Description:

This PR adds a new meta that specifically returns information from the browser's form validation API. This can be used to target HTML form elements, such as <input type="email">, and will return an object containing information about whether the element passes validation and whether it contains a message.

Invalid Example

Given the following:

render() {
    const value = 'test';
    const validity = this.meta(InputValidity).get('input', value);
    render (
        <input type="email" key="input" value={value}/>
    )
}

This meta will return the following:

{
    valid: false,
    message: "Please include an '@' in the email address. 'test' is missing an '@'."
}

Valid Example

Given the following:

render() {
    const value = 'test@example.com';
    const validity = this.meta(InputValidity).get('input', value);
    render (
        <input type="email" key="input" value={value}/>
    )
}

This meta will return the following:

{
    valid: true,
    message: ""
}

Copy link
Member

@tomdye tomdye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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

Successfully merging this pull request may close these issues.

2 participants