Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const metadataError = (error: ValidationError) => {
switch (error.kind) {
case Kind.INVALID_KEY: return `Invalid key: "${error.entry.key}". ${error.reason}`;
case Kind.INVALID_VALUE: return `Invalid ${tag(error.entry.key)} value: ${JSON.stringify(error.entry.value)}. ${error.reason}`;
case Kind.MULTIPLE_UNIQUE: return `Multiple ${tag(error.item.key)} values. Only one value is allowed.`;
case Kind.REQUIRED_MISSING: return `A ${tag(error.item.key)} entry is required, but none was found.`;
case Kind.UNRECOGNIZED_KEY: return `Unrecognized key: "${error.entry.key}".`;
default: throw new Error("Unknown metadata error.");
}
}