Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • database/drizzle/util/componentFieldConfig.ts

    rdda6f51 r5750945  
    108108    return true;
    109109}
     110
     111export function getValidationError(type: string, specificData: any): string | null {
     112    if (!(type in requiredFields)) {
     113        return `Invalid component type: ${type}`;
     114    }
     115
     116    const fields = requiredFields[type as ComponentType];
     117    const missingFields: string[] = [];
     118
     119    for (const field of fields) {
     120        const value = specificData[field];
     121        if (value === undefined || value === null || value === '') {
     122            missingFields.push(field);
     123        }
     124    }
     125
     126    if (missingFields.length > 0) {
     127        return `Missing required fields: ${missingFields.join(', ')}`;
     128    }
     129
     130    return null;
     131}
Note: See TracChangeset for help on using the changeset viewer.