diff --git a/README.md b/README.md index e377501c..14ddde15 100644 --- a/README.md +++ b/README.md @@ -48,12 +48,8 @@ Integrating CSV validation into CI processes promotes higher data integrity, rel * [demo.csv](tests/fixtures/demo.csv) -## Usage - -Also see demo in the [GitHub Actions](https://github.com/JBZoo/Csv-Blueprint/actions/workflows/demo.yml) file. - ### Schema Definition -Define your CSV validation schema in a YAML file. +Define your CSV validation schema in a [YAML](schema-examples/full.yml). Other formats are also available: , [JSON](schema-examples/full.json), [PHP](schema-examples/full.php). This example defines a simple schema for a CSV file with a header row, specifying that the `id` column must not be empty and must contain integer values. Also, it checks that the `name` column has a minimum length of 3 characters. @@ -74,6 +70,9 @@ columns: ``` + +### Full description of the scheme + In the [example Yml file](schema-examples/full.yml) you can find a detailed description of all features. It's also covered by tests, so it's always up-to-date. @@ -85,10 +84,6 @@ It's also covered by tests, so it's always up-to-date. * You are always free to add your option anywhere (except the `rules` list) and it will be ignored. I find it convenient for additional integrations and customization. -### Schema file examples - -Available formats: [YAML](schema-examples/full.yml), [JSON](schema-examples/full.json), [PHP](schema-examples/full.php). - ```yml # It's a full example of the CSV schema file in YAML format. @@ -223,6 +218,11 @@ columns: ``` +## Usage + +You can find launch examples in the [workflow demo](https://github.com/JBZoo/Csv-Blueprint/actions/workflows/demo.yml). + + ### As GitHub Action ```yml @@ -436,6 +436,8 @@ It's random ideas and plans. No orderings and deadlines. But batch processing **Validation** * More aggregate rules. +* More cell rules. +* `required` flag for the column. * Custom cell rule as a callback. It's useful when you have a complex rule that can't be described in the schema file. * Custom agregate rule as a callback. It's useful when you have a complex rule that can't be described in the schema file. * Configurable keyword for null/empty values. By default, it's an empty string. But you will use `null`, `nil`, `none`, `empty`, etc. Overridable on the column level. diff --git a/tests/Rules/Cell/RegexTest.php b/tests/Rules/Cell/RegexTest.php index 09a395f5..19bcb4e3 100644 --- a/tests/Rules/Cell/RegexTest.php +++ b/tests/Rules/Cell/RegexTest.php @@ -32,6 +32,7 @@ public function testPositive(): void isSame('', $rule->test('abc')); isSame('', $rule->test('aaa')); isSame('', $rule->test('a')); + isSame('', $rule->test('')); $rule = $this->create('^a'); isSame('', $rule->test('abc')); diff --git a/tests/schemas/example_full.yml b/tests/schemas/example_full.yml index c2cc0e87..a7366183 100644 --- a/tests/schemas/example_full.yml +++ b/tests/schemas/example_full.yml @@ -34,7 +34,46 @@ csv: # How to parse file before validation columns: - name: General available options # Can be optional if csv\header: false. If set, then header must contain this value required: true # If true, then column must be present in the file + rules: + is_ip6: true + dateperiod_: true + dateinterval_: true + bic: true + iban: true + card_number: true + country_code: true + currency_code: true + is_positive: true + is_negative: true + is_zero: true + is_even: true + is_odd: true + is_prime: true + is_time: true + is_timezone: true + is_timezone_offset: true aggregate_rules: + sum_: true + avg_: true + median_: true + mode_: true + range_: true + variance_: true + stddev_: true + percentile_: true + quantile_: true + count_: true + count_distinct_: true + count_empty_: true + count_not_empty_: true + count_null_: true + count_not_null_: true + count_zero_: true + count_positive_: true + count_negative_: true + count_even_: true + count_odd_: true + count_prime_: true sorted: asc # asc, desc, none sorted_flag: SORT_NATURAL # See sort flags: https://www.php.net/manual/en/function.sort.php count_min: 1