envguard-validator
v2.1.0
Published
Node.js wrapper for EnvGuard — validate .env files against a YAML schema
Downloads
1,183
Maintainers
Readme
envguard-validator
Node.js wrapper for EnvGuard — validate
.envfiles against a declarative YAML schema.
Install
npm install envguard-validatorThe correct EnvGuard binary for your platform is downloaded automatically via postinstall.
Quick Start
import { validate } from "envguard-validator";
const result = await validate({
schemaPath: "envguard.yaml",
envPath: ".env",
});
if (!result.valid) {
for (const error of result.errors) {
console.log(`${error.key}: ${error.message}`);
}
process.exit(1);
}
console.log("✓ Environment validated!");Synchronous API
import { validateSync } from "@envguard/node";
const result = validateSync({ schemaPath: "envguard.yaml", envPath: ".env" });CLI
npx envguard-validator validate --schema envguard.yaml --env .envAPI
validate(options?) → Promise<ValidationResult>
Options:
schemaPath— path to schema YAML (default:envguard.yaml)envPath— path to.envfile (default:.env)strict— fail on unknown keys in.env(default:false)
Returns:
ValidationResult.valid—booleanValidationResult.errors—ValidationError[]ValidationResult.warnings—ValidationError[]
Each ValidationError has:
key— variable namemessage— human-readable errorrule— rule that failed (required,type,pattern,enum,strict)
License
MIT
