From caa5aa47dc577c877536a102f9ec2b92d1b5a244 Mon Sep 17 00:00:00 2001 From: Mihajlo Date: Mon, 18 Apr 2022 14:49:57 +0200 Subject: [PATCH] fix: isSpecialMissing from utils --- src/utils/convertToCsv.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/convertToCsv.ts b/src/utils/convertToCsv.ts index bab7788..46007dd 100644 --- a/src/utils/convertToCsv.ts +++ b/src/utils/convertToCsv.ts @@ -1,3 +1,5 @@ +import { isSpecialMissing } from '@sasjs/utils' + /** * Converts the given JSON object array to a CSV string. * @param data - the array of JSON objects to convert. @@ -18,7 +20,6 @@ export const convertToCSV = ( let headers: string[] = [] let csvTest let invalidString = false - const specialMissingValueRegExp = /^[a-z_]{1}$/i if (formats) { headers = Object.keys(formats).map((key) => `${key}:${formats![key]}`) @@ -36,7 +37,7 @@ export const convertToCSV = ( hasNullOrNumber = true } else if ( typeof row[field] === 'string' && - specialMissingValueRegExp.test(row[field]) + isSpecialMissing(row[field]) ) { hasSpecialMissingString = true } @@ -130,10 +131,10 @@ export const convertToCSV = ( value = currentCell === null ? '' : currentCell if (formats && formats[fieldName] === 'best.') { - if (value && !specialMissingValueRegExp.test(value)) { + if (value && !isSpecialMissing(value)) { console.log(`🤖[value]🤖`, value) throw new Error( - 'Special missing value can only be a single character from A to Z or _' + 'A Special missing value can only be a single character from A to Z or _ or .[a-z] or ._' ) }