Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Smet committed Mar 11, 2024
1 parent 06e1508 commit 02f7723
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 21 deletions.
Binary file added .github/assets/output-text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 30 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,32 +200,41 @@ As a result of the validation process, you will receive a human-readable table w
Default output format is `table`:

```
./csv-blueprint validate:csv --output=table --csv=./tests/fixtures/demo.csv --schema=./tests/schemas/demo_invalid.yml
CSV : ./tests/fixtures/demo.csv
Schema : ./tests/schemas/demo_invalid.yml
+------+------------------+--------------+-- demo.csv -------------------------------------------+
| Line | id:Column | Rule | Message |
+------+------------------+--------------+-------------------------------------------------------+
| 1 | 1: | csv.header | Property "name" is not defined in schema: |
| | | | "./tests/schemas/demo_invalid.yml" |
| 5 | 2:Float | max | Value "74605.944" is greater than "74605" |
| 5 | 4:Favorite color | allow_values | Value "blue" is not allowed. Allowed values: ["red", |
| | | | "green", "Blue"] |
| 6 | 0:Name | min_length | Value "Carl" (legth: 4) is too short. Min length is 5 |
| 6 | 3:Birthday | min_date | Value "1955-05-14" is less than the minimum date |
| | | | "1955-05-15T00:00:00.000+00:00" |
| 8 | 3:Birthday | min_date | Value "1955-05-14" is less than the minimum date |
| | | | "1955-05-15T00:00:00.000+00:00" |
| 9 | 3:Birthday | max_date | Value "2010-07-20" is more than the maximum date |
| | | | "2009-01-01T00:00:00.000+00:00" |
| 11 | 0:Name | min_length | Value "Lois" (legth: 4) is too short. Min length is 5 |
| 11 | 4:Favorite color | allow_values | Value "blue" is not allowed. Allowed values: ["red", |
| | | | "green", "Blue"] |
+------+------------------+--------------+-- demo.csv -------------------------------------------+
CSV file is not valid! Found 9 errors.
+------+------------------+--------------+-- demo.csv --------------------------------------------+
| Line | id:Column | Rule | Message |
+------+------------------+--------------+--------------------------------------------------------+
| 1 | 1: | csv.header | Property "name" is not defined in schema: |
| | | | "./tests/schemas/demo_invalid.yml" |
| 5 | 2:Float | max | Value "74605.944" is greater than "74605" |
| 5 | 4:Favorite color | allow_values | Value "blue" is not allowed. Allowed values: ["red", |
| | | | "green", "Blue"] |
| 6 | 0:Name | min_length | Value "Carl" (length: 4) is too short. Min length is 5 |
| 6 | 3:Birthday | min_date | Value "1955-05-14" is less than the minimum date |
| | | | "1955-05-15T00:00:00.000+00:00" |
| 8 | 3:Birthday | min_date | Value "1955-05-14" is less than the minimum date |
| | | | "1955-05-15T00:00:00.000+00:00" |
| 9 | 3:Birthday | max_date | Value "2010-07-20" is more than the maximum date |
| | | | "2009-01-01T00:00:00.000+00:00" |
| 11 | 0:Name | min_length | Value "Lois" (length: 4) is too short. Min length is 5 |
+------+------------------+--------------+-- demo.csv --------------------------------------------+
CSV file is not valid! Found 8 errors.
```

Optional output format `text`:
```sh
./csv-blueprint validate:csv --output=text --csv=./tests/fixtures/demo.csv --schema=./tests/schemas/demo_invalid.yml
```

![Output - Text](.github/assets/output-text.png)


### Schema Definition
Define your CSV validation schema in a YAML file.
Expand Down
9 changes: 9 additions & 0 deletions tests/Blueprint/CommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ public function testCreateValidateNegative(): void

isSame(1, $exitCode);
isSame($expected, $actual);

isFileContains(\implode("\n", [
'```',
'./csv-blueprint validate:csv --output=table --csv=./tests/fixtures/demo.csv --schema=./tests/schemas/demo_invalid.yml',
'',
'',
\str_replace($rootPath, '.', $expected),
'```',
]), PROJECT_ROOT . '/README.md');
}

public function testCreateValidateNegativeText(): void
Expand Down

0 comments on commit 02f7723

Please sign in to comment.