Documentation
¶
Overview ¶
Package csv provides methods for easily validating the rows and columns of a CSV file.
Index ¶
- func Column(field string, validators ...validator) column
- func ColumnWithDefault(field, defaultValue string, validators ...validator) column
- func EqualToCrosConfigProp(ctx context.Context, path, prop string) validator
- func EqualToFileContent(path string) validator
- func EqualToFileIfCrosConfigProp(ctx context.Context, path, prop, filePath string) validator
- func MatchRegex(regex *regexp.Regexp) validator
- func MatchValue(value string) validator
- func Rows(expectedRows int) int
- func UInt64() validator
- func ValidateCSV(csv [][]string, rows int, columns ...column) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Column ¶
func Column(field string, validators ...validator) column
Column returns the field name of the column and a validator that will use a list of validators to validate all values in this CSV column. The return value is of the column type.
func ColumnWithDefault ¶
func ColumnWithDefault(field, defaultValue string, validators ...validator) column
ColumnWithDefault returns the field name of the column and a validator that will use a list of validators to validate all values in this CSV column. If the field value is equal to |defaultValue|, the validators are not run.
func EqualToCrosConfigProp ¶
EqualToCrosConfigProp returns a function that uses crosconfig and its two arguments, |prop| and |path| to obtain a value that is compared with |actual|.
func EqualToFileContent ¶
func EqualToFileContent(path string) validator
EqualToFileContent returns a function that checks whether |path| exists. If it does, it compares the value at that location wih |actual|. If it does not, an error is returned.
func EqualToFileIfCrosConfigProp ¶
EqualToFileIfCrosConfigProp returns a function that checks whether |filePath| should exist by using crosconfig and its two arguments, |prop| and |path|. If the crosconfig property does not exist, an error is returned. If the file exists, it attempts to read the value from the file. If it cannot, an error is reported. If it can, it compares the read value with |actual|.
func MatchRegex ¶
MatchRegex returns a function that checks whether |actual| matches the regex pattern specified by |regex|.
func MatchValue ¶
func MatchValue(value string) validator
MatchValue returns a validator that checks whether |value| is equal to |actual|.
func UInt64 ¶
func UInt64() validator
UInt64 returns a validator that checks whether |actual| can be parsed into a uint64.
func ValidateCSV ¶
ValidateCSV is responsible for validating headers and all values of the CSV output. An error is returned if the headers are invalid or if any of the CSV values are incorrect as determined by the validators provided to verify a particular CSV value.
Types ¶
This section is empty.