Skip to content
Snippets Groups Projects
Commit 10171790 authored by michael.minelli's avatar michael.minelli
Browse files

ExerciseResultsFile => Migrate to zod format

parent 70123251
No related branches found
No related tags found
No related merge requests found
interface ExerciseResultsFile {
success?: boolean;
import Icon from '../Icon';
import { z } from 'zod';
containerExitCode?: number;
successfulTests?: number;
failedTests?: number;
const ExerciseResultsFile = z.object({
success: z.boolean().optional(),
successfulTestsList?: Array<string>;
failedTestsList?: Array<string>;
containerExitCode: z.number().optional(),
successfulTests: z.number().optional(),
failedTests : z.number().optional(),
successfulTestsList: z.array(z.string()).optional(),
failedTestsList : z.array(z.string()).optional(),
otherInformations: z.array(z.object({
name : z.string(),
description : z.string().optional(),
icon : z.enum(Object.keys(Icon) as [ firstKey: string, ...otherKeys: Array<string> ]).optional().transform(value => value ? (Icon as { [index: string]: string })[value] : undefined),
itemsOrInformations: z.union([ z.array(z.string()), z.string() ])
}))
.optional()
}).strict().transform(value => {
if ( value.successfulTests === undefined && value.successfulTestsList !== undefined ) {
value.successfulTests = value.successfulTestsList.length;
}
if ( value.failedTests === undefined && value.failedTestsList !== undefined ) {
value.failedTests = value.failedTestsList.length;
}
return value;
});
type ExerciseResultsFile = z.infer<typeof ExerciseResultsFile>;
export default ExerciseResultsFile;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment