It seems it is not yet possible to use an async sanitizer function inside cast, do i mistake ?
If not, would it be possible to add support for this ?
Example
Sanitizer
import { Result } from '@restless/sanitizers';
export const asCertificate = async (value, path: string) => {
const errors = (await validate(value)) as any[];
if (Object.keys(errors).length) {
const resultError = flatten(
Object.values(errors).map((error) => {
return error.map((error) => ({
path: `${path}${error.path}`,
expected: error.expected || '',
}));
})
);
console.log(resultError);
return Result.error(resultError);
}
return Result.ok(value as Certificate);
};
Cast
import {cast} from '@restless/sanitizers';
import {asCertificate} from './somewhere';
const certificate = {};
const value = cast(certificate, asCertificate);
It seems it is not yet possible to use an async
sanitizerfunction insidecast, do i mistake ?If not, would it be possible to add support for this ?
Example
Sanitizer
Cast