feat: Use Typescript, YAML, Handlebars with generation workflow

Took 5 hours 7 minutes
This commit is contained in:
Lucàs
2025-07-14 00:27:06 +02:00
parent 3318a6cede
commit 48bde33a0e
40 changed files with 604 additions and 428 deletions
+43
View File
@@ -0,0 +1,43 @@
import type {ZodObject} from 'zod';
/**
* Validator class for validating and parsing objects against a Zod schema.
*/
export class Validator {
/**
* Creates an instance of the Validator.
* @param schema - The Zod schema to validate against.
*/
constructor(private schema: ZodObject<any, any>) {
}
/**
* Validates the given value against the schema.
* @param value - The object to validate.
* @returns true if the value is valid, false otherwise.
*/
public isValid(value: object): boolean {
try {
this.schema.parse(value);
return true;
} catch (error) {
console.error('Validation error:', error);
return false;
}
}
/**
* Parses the given value against the schema.
* @param value - The object to parse.
* @returns The parsed object if valid, throws an error otherwise.
*/
public validate(value: object): object {
try {
return this.schema.parse(value);
} catch (error) {
console.error('Parsing error:', error);
throw new Error('Failed to parse value');
}
}
}
+7
View File
@@ -0,0 +1,7 @@
import {z} from 'zod';
export const AuthorSchema = z.object({
first_name: z.string(),
location: z.string(),
company: z.string(),
});
+8
View File
@@ -0,0 +1,8 @@
import {z} from 'zod';
import {AuthorSchema, SkillSchema, SocialSchema} from '.';
export const ReadmeSchema = z.object({
author: AuthorSchema,
socials: z.array(SocialSchema),
skills: z.array(SkillSchema),
});
+6
View File
@@ -0,0 +1,6 @@
import {z} from 'zod';
export const SkillSchema = z.object({
name: z.string(),
icon: z.string(),
});
+7
View File
@@ -0,0 +1,7 @@
import {z} from 'zod';
export const SocialSchema = z.object({
name: z.string(),
icon: z.string(),
url: z.string(),
});
+4
View File
@@ -0,0 +1,4 @@
export * from './AuthorSchema';
export * from './SocialSchema';
export * from './SkillSchema';
export * from './ReadmeSchema';