Remove unused function plus tests
This commit is contained in:
@@ -54,41 +54,3 @@ export function formatFieldLabel(key: string): string {
|
||||
.replace(/_/g, " ") // Replace underscores with spaces
|
||||
.replace(/^\w/, (c) => c.toUpperCase()); // Capitalize first letter
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates if a value conforms to a JSON schema
|
||||
* @param value The value to validate
|
||||
* @param schema The JSON schema to validate against
|
||||
* @returns True if valid, false otherwise
|
||||
*/
|
||||
export function validateValueAgainstSchema(
|
||||
value: JsonValue,
|
||||
schema: JsonSchemaType,
|
||||
): boolean {
|
||||
// Handle undefined values for non-required fields
|
||||
if (value === undefined && !schema.required) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Basic type validation
|
||||
switch (schema.type) {
|
||||
case "string":
|
||||
return typeof value === "string";
|
||||
case "number":
|
||||
return typeof value === "number";
|
||||
case "integer":
|
||||
return typeof value === "number" && Number.isInteger(value);
|
||||
case "boolean":
|
||||
return typeof value === "boolean";
|
||||
case "array":
|
||||
return Array.isArray(value);
|
||||
case "object":
|
||||
return (
|
||||
typeof value === "object" && value !== null && !Array.isArray(value)
|
||||
);
|
||||
case "null":
|
||||
return value === null;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user