mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-07 12:30:06 +00:00
fix: isSpecialMissing from utils
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import { isSpecialMissing } from '@sasjs/utils'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the given JSON object array to a CSV string.
|
* Converts the given JSON object array to a CSV string.
|
||||||
* @param data - the array of JSON objects to convert.
|
* @param data - the array of JSON objects to convert.
|
||||||
@@ -18,7 +20,6 @@ export const convertToCSV = (
|
|||||||
let headers: string[] = []
|
let headers: string[] = []
|
||||||
let csvTest
|
let csvTest
|
||||||
let invalidString = false
|
let invalidString = false
|
||||||
const specialMissingValueRegExp = /^[a-z_]{1}$/i
|
|
||||||
|
|
||||||
if (formats) {
|
if (formats) {
|
||||||
headers = Object.keys(formats).map((key) => `${key}:${formats![key]}`)
|
headers = Object.keys(formats).map((key) => `${key}:${formats![key]}`)
|
||||||
@@ -36,7 +37,7 @@ export const convertToCSV = (
|
|||||||
hasNullOrNumber = true
|
hasNullOrNumber = true
|
||||||
} else if (
|
} else if (
|
||||||
typeof row[field] === 'string' &&
|
typeof row[field] === 'string' &&
|
||||||
specialMissingValueRegExp.test(row[field])
|
isSpecialMissing(row[field])
|
||||||
) {
|
) {
|
||||||
hasSpecialMissingString = true
|
hasSpecialMissingString = true
|
||||||
}
|
}
|
||||||
@@ -130,10 +131,10 @@ export const convertToCSV = (
|
|||||||
value = currentCell === null ? '' : currentCell
|
value = currentCell === null ? '' : currentCell
|
||||||
|
|
||||||
if (formats && formats[fieldName] === 'best.') {
|
if (formats && formats[fieldName] === 'best.') {
|
||||||
if (value && !specialMissingValueRegExp.test(value)) {
|
if (value && !isSpecialMissing(value)) {
|
||||||
console.log(`🤖[value]🤖`, value)
|
console.log(`🤖[value]🤖`, value)
|
||||||
throw new Error(
|
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 ._'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user