env-sentinel
Version:
Zero-dependency tool that auto-validates .env files against schema.env, with optional fallback and secure warnings.
22 lines (21 loc) • 676 B
JavaScript
export function secureValueValidator(key, value) {
if (value.length < 8) {
return `${key} must be at least 8 characters long`;
}
if (!/[a-z]/.test(value)) {
return `${key} must contain at least one lowercase letter`;
}
if (!/[A-Z]/.test(value)) {
return `${key} must contain at least one uppercase letter`;
}
if (!/\d/.test(value)) {
return `${key} must contain at least one number`;
}
if (!/[!@#$%^&*(),.?":{}|<>]/.test(value)) {
return `${key} must contain at least one special character`;
}
if (/\s/.test(value)) {
return `${key} must not contain spaces`;
}
return true;
}