Expand description

valve.rs

A lightweight validation engine written in rust.

This implementation is a port of the next implementation of the valve parser to rust.

Command line usage

valve table db

where table is the path to the table table (normally table.tsv) and db is the path to the sqlite database file (which is created if it doesn’t exist).

Python bindings

See valve.py

Modules

Structs

Represents a ‘when-then’ condition, as found in the rule table, as two CompiledCondition structs corresponding to the when and then parts of the given rule.

Represents a condition in three different ways: (i) in String format, (ii) as a parsed Expression, and (iii) as a pre-compiled regular expression.

Represents a structure such as those found in the structure column of the column table in both its parsed format (i.e., as an Expression) as well as in its original format (i.e., as a plain String).

Functions

Given a path to a table table file (table.tsv), a directory in which to find/create a database: configure the database using the configuration which can be looked up using the table table, and optionally load it if the load flag is set to true.

Given config maps for tables and datatypes, a database connection pool, and a StartParser, read in the TSV files corresponding to the tables defined in the tables config, and use that information to fill in constraints information into a new config map that is then returned. If the flag write_sql_to_stdout is set to true, emit SQL to create the database schema to STDOUT. If the flag write_to_db is set to true, execute the SQL in the database using the given connection pool.

Given the global configuration map and a parser, compile all of the datatype conditions, add them to a hash map whose keys are the text versions of the conditions and whose values are the compiled conditions, and then finally return the hash map.

Given the global config map, a hash map of compiled datatype conditions (indexed by the text version of the conditions), and a parser, compile all of the rule conditions, add them to a hash which has the following structure:

Given the global config map and a parser, parse all of the structure conditions, add them to a hash map whose keys are given by the text versions of the conditions and whose values are given by the parsed versions, and finally return the hashmap.

Given a database connection pool, a table name, and a row, assign a new row number to the row and insert it to the database, then return the new row number.

Given a configuration map, a database connection pool, a parser, HashMaps representing compiled datatype and rule conditions, and a HashMap representing parsed structure conditions, read in the data TSV files corresponding to each configured table, then validate and load all of the corresponding data rows.

Given the path to a table.tsv file, load and check the ‘table’, ‘column’, and ‘datatype’ tables, and return ConfigMaps corresponding to specials, tables, datatypes, and rules.

Given a database connection pool, a table name, a row, and the row number to update, update the corresponding row in the database with new values as specified by row.

Type Definitions