Skip to content

Commit

Permalink
Make validation optional ( singer-io#25 )
Browse files Browse the repository at this point in the history
  • Loading branch information
fertek committed Oct 12, 2020
1 parent 88bedc0 commit e4736be
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions target_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_headers(schema, parent_key=DEFAULT_PARENT_KEY, sep=SEP):
def generate_key(parent_key, sep, key):
return parent_key + sep + key if parent_key else key

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

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

filename = o['stream'] + '.csv'
filename = os.path.expanduser(os.path.join(destination_path, filename))
Expand Down Expand Up @@ -144,7 +145,8 @@ def main():
state = persist_messages(config.get('delimiter', ','),
config.get('quotechar', '"'),
input_messages,
config.get('destination_path', ''))
config.get('destination_path', ''),
config.get('validate_records', True))

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

0 comments on commit e4736be

Please sign in to comment.