Skip to content

Commit

Permalink
Merge pull request #1603 from johan13/io-ts-parse-safe
Browse files Browse the repository at this point in the history
feat: add parseSafe case for io-ts
  • Loading branch information
DarkGL authored Jan 29, 2025
2 parents f0a20b3 + 41e6650 commit dae20d4
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cases/io-ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,31 @@ createCase('io-ts', 'assertLoose', () => {
);
};
});

createCase('io-ts', 'parseSafe', () => {
const dataType = t.strict({
number: t.Int,
negNumber: t.number,
maxNumber: t.number,
string: t.string,
longString: t.string,
boolean: t.boolean,
deeplyNested: t.strict({
foo: t.string,
num: t.number,
bool: t.boolean,
}),
});

return data => {
return pipe(
dataType.decode(data),
fold(
errors => {
throw errors;
},
result => result,
),
);
};
});

0 comments on commit dae20d4

Please sign in to comment.