fix(striker-ui): add file related schemas

main
Tsu-ba-me 1 year ago
parent 2e2450b8b9
commit 13994880ac
  1. 29
      striker-ui/components/Files/schema.ts

@ -0,0 +1,29 @@
import * as yup from 'yup';
import buildYupDynamicObject from '../../lib/buildYupDynamicObject';
const fileLocationSchema = yup.object({ active: yup.boolean().required() });
const fileLocationAnvilSchema = yup.lazy((anvils) =>
yup.object(buildYupDynamicObject(anvils, fileLocationSchema)),
);
const fileLocationDrHostSchema = yup.lazy((drHosts) =>
yup.object(buildYupDynamicObject(drHosts, fileLocationSchema)),
);
const fileSchema = yup.object({
locations: yup.object({
anvils: fileLocationAnvilSchema,
drHosts: fileLocationDrHostSchema,
}),
name: yup.string().required(),
type: yup.string().oneOf(['iso', 'other', 'script']),
uuid: yup.string().uuid().required(),
});
const fileListSchema = yup.lazy((files) =>
yup.object(buildYupDynamicObject(files, fileSchema)),
);
export default fileListSchema;
Loading…
Cancel
Save