I’ve released rescript-struct@0.23.0 with the support for asynchronous refinements and transforms.
let userIdStruct = S.string()->S.asyncRefine(~parser=string =>
verfiyUserExistsInDb(~userId=string)->Promise.thenResolve(isExistingUser =>
if not(isExistingUser) {
S.Error.raise("User doesn't exist")
}
)
, ())
"1234"->S.parseAsyncWith(userIdStruct)
Also, this release brought a noticeable boost of performance, making rescript-struct just a little bit slower than decco (benchmark).