diff --git a/main.ts b/main.ts index 1fb78b3..28803fb 100644 --- a/main.ts +++ b/main.ts @@ -6,6 +6,7 @@ import { IsIn, IsNotEmptyObject, IsString, + MaxLength, validate, } from "class-validator" import { js2xml } from "xml-js" @@ -34,6 +35,14 @@ export async function generateKlc( throw new Error(errors.map((e) => e.toString()).join(", ")) } + const windowsErrors = await validate( + plainToClass(WindowsAttributes, layout.os.windows) + ) + + if (windowsErrors.length) { + throw new Error(windowsErrors.map((e) => e.toString()).join(", ")) + } + const klcLocales = { Thai: "th-TH", } @@ -435,5 +444,19 @@ export class Layout { } interface OSAttributes { - windows: { company: string; localeId: string; installerName: string } + windows: WindowsAttributes +} + +class WindowsAttributes { + @IsString() + company: string + + @IsString() + localeId: string + + @IsString() + @MaxLength(8, { + message: "Installer name cannot be longer than 8 characters", + }) + installerName: string }