{"size": 733, "ext": "js", "max_stars_repo_path": "src/mantine-hooks/cjs/use-validated-state/use-validated-state.js", "max_stars_repo_name": "b93de3d/mantine-fork", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/mantine-hooks/cjs/use-validated-state/use-validated-state.js", "max_issues_repo_name": "b93de3d/mantine-fork", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/mantine-hooks/cjs/use-validated-state/use-validated-state.js", "max_forks_repo_name": "b93de3d/mantine-fork", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.32, "max_line_length": 111, "alphanum_fraction": 0.7012278308}
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var react = require('react');

function useValidatedState(initialValue, validation) {
  const [value, setValue] = react.useState(initialValue);
  const [lastValidValue, setLastValidValue] = react.useState(validation(initialValue) ? initialValue : void 0);
  const [valid, setValid] = react.useState(validation(initialValue));
  const onChange = (val) => {
    if (validation(val)) {
      setLastValidValue(val);
      setValid(true);
    } else {
      setValid(false);
    }
    setValue(val);
  };
  return [{ value, lastValidValue, valid }, onChange];
}

exports.useValidatedState = useValidatedState;
//# sourceMappingURL=use-validated-state.js.map
