Concise decoding of a nullish string into an Option of a non-empty string
Is there a more concise way to decode a nullish string into an Option of a non empty string?
Schema.transform(
Schema.NullishOr(Schema.String),
Schema.OptionFromSelf(Schema.NonEmptyString),
{
encode: Option.getOrNull,
decode: (value) =>
pipe(
value,
Option.fromNullable,
Option.flatMap(Option.liftPredicate(String.isNonEmpty)),
),
},
),