Categorygithub.com/markelrep/csvalidator
modulepackage
0.2.8
Repository: https://github.com/markelrep/csvalidator.git
Documentation: pkg.go.dev

# README

CSValidator

CSValidator is a tool for validation of .csv files using JSON schema

Quick Start

Install

go get -u github.com/markelrep/csvalidator

Schema

{
  "columns":[
    {
      "name": "id",
      "required": true
    },
    {
      "name": "comment",
      "required": false
    }
  ]
}

columns is array of objects with validation rules for each columns in .csv file

name of column, which should be the same as in .csv file otherwise validation will be failed. This field also supports regexp. Example

required true means that this column is required to exist in file, false that isn't required

Usage

package main
import "github.com/markelrep/csvalidator"

func main() {
	validator, err := csvalidator.NewValidator(csvalidator.Config{
		FilePath:       "./path/to/csv/files",
		FirstIsHeader:  true,
		SchemaPath:     "./path/to/json/schema",
		WorkerPoolSize: 0,
		// If ErrFilePath is defined then all errors with be written to this file else to the std our 
		ErrFilePath "./path/to/dst/file/with/errors"
	})
	if err != nil {
		// handle error
    }
	if err := validator.Validate(); err != nil {
		// handle error
	}
}

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

NewValidator creates a new Validator.

# Structs

Validator stores csv files which to be validated and validate rules.