gillchristian / Io Ts Reporters
Licence: mit
Error reporters for io-ts
Stars: ✭ 58
Programming Languages
typescript
32286 projects
Labels
Projects that are alternatives of or similar to Io Ts Reporters
Dry Validation
Validation library with type-safe schemas and rules
Stars: ✭ 1,087 (+1774.14%)
Mutual labels: type-safety, validation
Flow Runtime
A runtime type system for JavaScript with full Flow compatibility.
Stars: ✭ 813 (+1301.72%)
Mutual labels: type-safety, validation
Typical
Typical: Fast, simple, & correct data-validation using Python 3 typing.
Stars: ✭ 111 (+91.38%)
Mutual labels: type-safety, validation
Typewiz
Automatically discover and add missing types in your TypeScript code
Stars: ✭ 1,026 (+1668.97%)
Mutual labels: type-safety
Arg.js
🇦🇷 🛠 NPM library. Validation of Argentinian bank account numbers, IDs and phone numbers
Stars: ✭ 52 (-10.34%)
Mutual labels: validation
Schemas
All schemas used for validation that are shared between our projects
Stars: ✭ 51 (-12.07%)
Mutual labels: validation
Vs Validation
Common input and integrity validation routines for Visual Studio and other applications
Stars: ✭ 48 (-17.24%)
Mutual labels: validation
Laravel Smart
Automatic Migrations, Validation and More
Stars: ✭ 48 (-17.24%)
Mutual labels: validation
Celebrate
A joi validation middleware for Express.
Stars: ✭ 1,041 (+1694.83%)
Mutual labels: validation
Formik Alicante
Formik slides & demos from React Alicante
Stars: ✭ 47 (-18.97%)
Mutual labels: validation
Cpf
Validar, formatar e gerar números de CPF (validate, format and generate CPF numbers 🇧🇷).
Stars: ✭ 51 (-12.07%)
Mutual labels: validation
Mobx React Form
Reactive MobX Form State Management
Stars: ✭ 1,031 (+1677.59%)
Mutual labels: validation
Validate
This package provides a framework for writing validations for Go applications.
Stars: ✭ 57 (-1.72%)
Mutual labels: validation
Inicpp
C++ parser of INI files with schema validation.
Stars: ✭ 47 (-18.97%)
Mutual labels: validation
Awesomevalidation
Android validation library which helps developer boil down the tedious work to three easy steps.
Stars: ✭ 1,093 (+1784.48%)
Mutual labels: validation
io-ts-reporters
Error reporters for io-ts.
Currently this package only includes one reporter. The output is an array of strings in the format of:
Expecting ${expectedType} at ${path} but instead got: ${expectedType}
And for union types:
Expecting one of:
${unionType1}
${unionType2}
${...}
${unionTypeN}
at ${path} but instead got: ${actualValue}
Installation
yarn add io-ts-reporters
Example
import * as t from 'io-ts';
import reporter from 'io-ts-reporters';
const User = t.interface({ name: t.string });
// When decoding fails, the errors are reported
reporter.report(User.decode({ nam: 'Jane' }));
//=> ['Expecting string at name but instead got: undefined']
// Nothing gets reported on success
reporter.report(User.decode({ name: 'Jane' }));
//=> []
To only format the validation errors in case the validation failed (ie.
mapLeft
) use formatValidationErrors
instead.
import * as t from 'io-ts';
import { formatValidationErrors } from 'io-ts-reporters';
import * as E from 'fp-ts/lib/Either';
import { pipe } from 'fp-ts/lib/pipeable';
const User = t.interface({ name: t.string });
const result = User.decode({ nam: 'Jane' }); // Either<t.Errors, User>
E.mapLeft(formatValidationErrors)(result); // Either<string[], User>
For more examples see the tests.
TypeScript compatibility
io-ts-reporters version | required typescript version |
---|---|
1.0.0 | 3.5+ |
<= 0.0.21 | 2.7+ |
Testing
yarn
yarn run test
Credits
This library was created by OliverJAsh.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].