Effect CommunityEC
Effect Community•2y ago•
8 replies
marksuperbeurk

Determining Cause of Decode Failure

Hey everyone, what's the proper way to determine what errors caused a decode to fail ?

I mean, without using the error message, as it could change in the future

const schema = S.String.pipe(
  S.compose(S.Trim),
  S.minLength(1),
  S.maxLength(255),
);

const result = S.decode(schema, '   ');

Effect.match(result, {
    onFailure(error) {
       // this is what I need error.errors.find(_ => _.type === 'minLength')
    },
});


I tried using the annotations but to no avail 😞

Thanks in advance
Was this page helpful?