UnivalSanitize key-value or string files for consistency by detecting duplicate keys, values, or lines on the fly within a file or across a group of files. You can validate a file for duplicate keys, values, both keys and values or duplicate lines SampleDocumentationUnival is a configurable extension. You can customize the default configurations by adding a unival.json file at the root directory. To add a config file by command:
A sample unival.json file is shown below
The contents of this file are explained below under documentation. targetHere you can specify all files extensions in an array which you want to be validated by unival.
To validate all files set target to srcThis is an array of files or directories that unival will validate.
delimiterTo validate keys, values, or both key and value for duplicates, here you can specify the delimiter. For example, if you key values are delimited by an = symbol, like: greet_guest = Welcome Guest You need to specify the delimiter as below:
testByHere you can specify, if the validation for duplicates is based on key, value, both, or entire line For example to find only duplicate values in a file, you can set testBy to key as shown below
Other possible values for testBy are as follows:
groupsThis property is used to group two or more files and validate them for duplicates. That means unival will validate a file for duplication if no duplicates were found it will then try to find the duplicates across all files within the same group. For example, assuming the testBy value it set to “value” and we have two files within the same group as shown below: File 1 make_payment = Make payment File 2 pay = Make payment unival will consider Make payment as duplicate because this is same value in two files within the same group. The groups property is an array of arrays. Each array inside the group array is list of files to be grouped together. For example To group file1.txt and file2.txt within the same group, you can specify this as shown below:
To group all files in directory g1 in one group and all files in directory g2 in another group, you can set groups as shown below:
Any files within the subdirectories of g1 will be considered in same group as g1 encodingHere you can specify the encoding of your target files. The default value is utf-8
Skip linesYou probably are going to have comments in your files or you might want to ignoring files beginning with certain strings and to do so, you can use
whitelistTo whitelist a set of keys or values (value or line) so that they are considered as duplicate, simply add them to whitelist. A whitelist is an array of WhiteListItem which is explained below:
Case sensitivityUnival by default compares strings ignoring the case. To make unival to make case-sensitive comparisons while finding duplicates, simply set
LicenseCopyright (c) 2020-2020. Licensed under Apache License 2.0. |