Skip to content

Instantly share code, notes, and snippets.

View Pietro-Putelli's full-sized avatar

Pietro Putelli Pietro-Putelli

View GitHub Profile
const validateSchema = (data, schema, path = "", errors = []) => {
switch (schema.type) {
case "string":
if (typeof data !== "string") {
errors.push(`Expected type "string" but got ${typeof data} at ${path}`);
}
break;
case "number":
if (typeof data !== "number") {