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

Form: Standardize validation methods across input components #928

Open
Darper opened this issue Jul 24, 2018 · 0 comments
Open

Form: Standardize validation methods across input components #928

Darper opened this issue Jul 24, 2018 · 0 comments

Comments

@Darper
Copy link
Contributor

Darper commented Jul 24, 2018

In order to properly have a Form component that can validate Atlas input components (TextField, TextArea, Dropdown, etc.) they need to all have one method that can be called that will both validate the value and update state for value and messaging.

Currently, TextField has a _validate() method that (I think) does what we need.

_validate = (event, inputValue, change) => {
  const validationObject = utils.validate(
    inputValue,
    this.props.valid,
    this.props.status,
    this.props.message,
    this.props.required,
    event
  );

  this.setState(
    {
      "status": validationObject.status,
      "message": validationObject.message,
      "value": inputValue,
      "active": change
    },
    () => {
      this._eventHandlers(event, change);
    }
  );
};

There are two main issues that need to be solved.

  1. The event is not available when being called from an parent component via a ref.
  2. Other input components do not have a central method like this that can be called to both validate and set state properly.

This will block applications from being able to use our component validation inside a form.

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

No branches or pull requests

1 participant