-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
good first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
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);Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed