Skip to content

Commit

Permalink
Introduce TRIMMED_STRING custom codec
Browse files Browse the repository at this point in the history
  • Loading branch information
Pl217 committed Jun 12, 2024
1 parent 67fa795 commit e269979
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libs/hpc-data/src/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ export const BOOLEAN_FROM_STRING = new t.Type<boolean, boolean>(
t.identity
);

export const TRIMMED_STRING = new t.Type<string, string>(
'TRIMMED_STRING',
t.string.is,
(v, c) => {
if (typeof v === 'string') {
return t.success(v.trim());
}
return t.failure(v, c);
},
t.identity
);

/**
* A file BLOB
*/
Expand Down

0 comments on commit e269979

Please sign in to comment.