Skip to content

Commit

Permalink
Add empty_ok_if and empty_ok_unless (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
mboudet authored Nov 3, 2022
1 parent 5c8d942 commit 89a51df
Show file tree
Hide file tree
Showing 5 changed files with 252 additions and 25 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

This changelog was started for release 0.0.3.

## [0.0.3] - Unreleased

### Added

- empty_ok_if key for validator
- empty_ok_unless key for validator
- readme key for validator
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,15 @@ In all cases, you will need to at least include a list of validators and associa

* *metadata*: A list of column names. This will create a metadata sheet with these columns, without validation on them
* *empty_ok* (Default False): Whether to accept empty values as valid
* *empty_ok_if* (Default None): Accept empty value as valid if **another column** value is set
* Accept either a string (column name), a list (list of column names), or a dict
* The dict keys must be column names, and the values lists of 'accepted values'. The current column will accept empty values if the related column's value is in the list of accepted values
* *empty_ok_unless* (Default None): Accept empty value as valid *unless* **another column** value is set
* Accept either a string (column name), a list (list of column names), or a dict
* The dict keys must be column names, and the values lists of 'rejected values'. The current column will accept empty values if the related column's value is **not** in the list of reject values
* *ignore_space* (Default False): whether to trim the values for spaces before checking validity
* *ignore_case* (Default False): whether to ignore the case
* *readme* (Default None): Additional information to include on the readme page

The last 3 parameters will affect all the validators (when relevant), but can be overriden at the validator level (eg, you can set 'empty_ok' to True for all, but set it to False for a specific validator).

Expand Down
2 changes: 1 addition & 1 deletion checkcel/checkcel.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def _validate(self, row):
if column in self.validators:
validator = self.validators[column]
try:
validator.validate(row[column], self.line_count, row=row)
validator.validate(row[column], self.line_count, row)
except ValidationException as e:
self.failures[column][self.line_count].append(e)
validator.fail_count += 1
Expand Down
Loading

0 comments on commit 89a51df

Please sign in to comment.