env-sentinel
Version:
Zero-dependency tool that auto-validates .env files against schema.env, with optional fallback and secure warnings.
11 lines (10 loc) • 381 B
JavaScript
export function validateMaxValue(key, value, args) {
const max = Number(args[0]);
if (isNaN(max)) {
return `Invalid max argument for ${key}`;
}
if (value !== '' && !isNaN(Number(value))) {
return Number(value) > max ? `${key} must be <= ${max}` : true;
}
return value.length > max ? `${key} must be at most ${max} characters long` : true;
}