Skip to content

Commit

Permalink
Merge pull request #13 from hotgluexyz/fix/validation
Browse files Browse the repository at this point in the history
add validation option
  • Loading branch information
hsyyid authored Nov 16, 2021
2 parents 496a945 + 305adf7 commit 181488d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup

setup(name='target-csv',
version='0.3.5',
version='0.3.6',
description='Singer.io target for writing CSV files',
author='Stitch',
url='https://singer.io',
Expand Down
9 changes: 5 additions & 4 deletions target_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def flatten(d, parent_key='', sep='__'):
return dict(items)


def persist_messages(delimiter, quotechar, messages, destination_path, fixed_headers):
def persist_messages(delimiter, quotechar, messages, destination_path, fixed_headers, validate):
state = None
schemas = {}
key_properties = {}
Expand All @@ -59,8 +59,8 @@ def persist_messages(delimiter, quotechar, messages, destination_path, fixed_hea
if o['stream'] not in schemas:
raise Exception("A record for stream {}"
"was encountered before a corresponding schema".format(o['stream']))

validators[o['stream']].validate(o['record'])
if validate:
validators[o['stream']].validate(o['record'])

filename = o['stream'] + '-' + now + '.csv'
filename = os.path.expanduser(os.path.join(destination_path, filename))
Expand Down Expand Up @@ -153,7 +153,8 @@ def main():
config.get('quotechar', '"'),
input_messages,
config.get('destination_path', ''),
config.get('fixed_headers'))
config.get('fixed_headers'),
config.get('validate', True))

emit_state(state)
logger.debug("Exiting normally")
Expand Down

0 comments on commit 181488d

Please sign in to comment.