Skip to content

Commit

Permalink
Merge pull request #1014 from ibi-group/append-transform-fixes
Browse files Browse the repository at this point in the history
Only validate CSV headers when CSV has headers
  • Loading branch information
miles-grant-ibigroup authored May 16, 2024
2 parents 1efb3f0 + 9006ab6 commit ae16265
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/manager/components/transform/CustomCSVForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Props = {
onChangeCsvData: ({target: {name?: string, value: string}}) => void,
onSaveCsvData: () => void,
placeholder?: string,
validateHeaders?: boolean
}
const CustomCSVForm = (props: Props) => {
const [errorCount, setErrorCount] = useState(0)
Expand All @@ -34,9 +35,11 @@ const CustomCSVForm = (props: Props) => {
} = props

useEffect(() => {
// Default to true
const validateHeaders = props.validateHeaders !== undefined ? props.validateHeaders : true
setErrorCount(0)

parseString(csvData, { headers: true })
parseString(csvData, { headers: validateHeaders })
.on('error', _ => setErrorCount(errorCount + 1))
}, [csvData])

Expand Down
1 change: 1 addition & 0 deletions lib/manager/components/transform/ReplaceFileFromString.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default class ReplaceFileFromString extends Component<TransformProps<Repl
inputIsSame={inputIsSame}
onChangeCsvData={this._onChangeCsvData}
onSaveCsvData={this._onSaveCsvData}
validateHeaders={transformation['@type'] !== 'AppendToFileTransformation'}
/>
)
}
Expand Down

0 comments on commit ae16265

Please sign in to comment.