forked from huggingface/blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate-yaml.ts
45 lines (38 loc) · 1.22 KB
/
validate-yaml.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Use `deno fmt` to format this file.
import { parse } from "https://deno.land/[email protected]/yaml/mod.ts";
import { z } from "https://deno.land/x/[email protected]/mod.ts";
for (const lang of ["", "zh/"]) {
{
const relativePath = `${lang}_events.yml`;
console.log(`Validating ${relativePath}`);
z.array(z.object({
link: z.string().url(),
name: z.string(),
date: z.string(),
date_formatted: z.string().optional(),
description: z.string(),
})).parse(parse(Deno.readTextFileSync("../" + relativePath)));
}
{
const relativePath = `${lang}_blog.yml`;
console.log(`Validating ${relativePath}`);
z.array(z.object({
local: z.string().optional(),
external: z.string().optional(),
title: z.string(),
thumbnail: z.string().optional(),
author: z.string(),
guest: z.boolean().optional(),
date: z.string(),
tags: z.array(z.string()),
})).parse(parse(Deno.readTextFileSync("../" + relativePath)));
}
{
const relativePath = `${lang}_tags.yml`;
console.log(`Validating ${relativePath}`);
z.array(z.object({
value: z.string(),
label: z.string(),
})).parse(parse(Deno.readTextFileSync("../" + relativePath)));
}
}