# strictly-formed-io-ts

> io-ts wrapper for strictly-formed, a statically typed form library for typescript

Latest version **0.1.0** (published 2018-09-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install strictly-formed-io-ts
pnpm add strictly-formed-io-ts
yarn add strictly-formed-io-ts
bun add strictly-formed-io-ts
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2018-09-05 |
| First published | 2018-08-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 25 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | James Conkling |
| Maintainers | james.lane.conkling |
| Keywords | typescript, react, form, io-ts, types, validation |

## Links

- npm: https://www.npmjs.com/package/strictly-formed-io-ts
- Repository: https://github.com/sayari-analytics/strictly-formed-io-ts
- Homepage: https://github.com/sayari-analytics/strictly-formed-io-ts#README
- Issues: https://github.com/sayari-analytics/strictly-formed-io-ts/issues
- npm.io page: https://npm.io/package/strictly-formed-io-ts

## Dependencies (2)

- [io-ts](https://npm.io/package/io-ts.md) ^1.3.0
- [strictly-formed](https://npm.io/package/strictly-formed.md) ^0.2.2

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2018-09-05
- 0.0.2 — 2018-08-28
- 0.0.1 — 2018-08-28

## README

# Strictly Formed Io-TS

io-ts wrapper for [strictly-formed](https://github.com/sayari-analytics/strictly-formed), a statically typed form library for typescript.  Guarantee runtime type safety for custom static types.


# API

<!-- Form `value` props are typechecked according to their relevant types, as are the arguments passed to their handler callbacks.  In addition, where relevant, optional `onSubmit` and `onClear` handlers are bound to their respective `enter` and `esc` keys. -->
Validate form input against [io-ts](https://github.com/gcanti/io-ts) runtime types, wrapping input changes in a [fp-ts](https://github.com/gcanti/fp-ts) `Either<Error, T>` type.


**StringInput**
```typescript
type Props = {
  type: t.Type<T>,
  value: string | undefined
  className?: string
  placeholder?: string
  forwardedRef?: Ref<HTMLInputElement>
  onChange(validation: t.Validation<T>, value: string | undefined): void
  onSubmit?(value: T): void
  onClear?: () => void
}
```

```typescript
import t as * from 'io-ts';
import { StringInput } from 'strictly-formed-io-ts';

// EX - validate trimmed input is not empty
const NonEmptyStringIoTs = t.refinement(t.string, (str) => str.trim() !== '');
type NonEmptyString = t.TypeOf<typeof NonEmptyString>;

<StringInput<NonEmptyString>
  className="string-input"
  type={NonEmptyStringIoTs}
  value={copyDate}
  onChange={(validation, value) => {
    validation.fold(
      (validationErrors) => console.error(validationErrors),
      // ^^^^^^^^^^^^^^ - T.ValidationError[]
      (validValue) => console.log(validValue)
      // ^^^^^^^^ - NonEmptyString
    )
  }}
  onSubmit={submitString}
>
```


### Install

```bash
npm install strictly-formed
```

### License

[ISC](https://opensource.org/licenses/ISC)

---
_Source: https://npm.io/package/strictly-formed-io-ts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
