env-sentinel
Version:
Zero-dependency tool that auto-validates .env files against schema.env, with optional fallback and secure warnings.
11 lines (10 loc) • 359 B
JavaScript
export function validateEnumValue(key, value, args) {
const allowedValues = args;
if (!Array.isArray(allowedValues)) {
return `Invalid enum definition for ${key}, expected an array of allowed values`;
}
if (!allowedValues.includes(value)) {
return `${key} must be one of: ${allowedValues.join(', ')}`;
}
return true;
}