validator

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2021 License: MIT Imports: 9 Imported by: 0

README

dotenv-validator

CI codecov Go Report Card Go Reference

dotenv-validator is a simple package that validates your environment based upon a formatted .env.sample file. Based upon dotenv_validator from FastRuby.io.

Usage

Installation
go get github.com/duffn/dotenv-validator
Configuring your environment variables

Tell dotenv-validator how you expect your environment variables by commenting them in your .env.sample file.

VAR1=testing # required
VAR2=123 # format=int
VAR3=notrequired
VAR4=bob@bobloblaw.com # required,format=email
Formats
.env.sample
VAR1=bob # required
VAR2=lobloaw # required,format=str
VAR3=1.3415 # format=float
VAR4=ABCDEF # format=[A-Z]+
VAR5=notrequired
Running
package main

import (
	"fmt"

	validator "github.com/duffn/dotenv-validator"
)

func main() {
	err := validator.Validate()
	fmt.Println(err)
}

Choose your sample file.

package main

import (
	"fmt"

	validator "github.com/duffn/dotenv-validator"
)

func main() {
	err := validator.ValidateWithFilename("env_sample")
	fmt.Println(err)
}

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate() error

func ValidateWithFilename

func ValidateWithFilename(filename string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL