Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only validate CSV headers when CSV has headers #1014

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do ES Lint rules apply to this repo? I know there are rules for a multiline ternary.

Copy link
Contributor Author

@miles-grant-ibigroup miles-grant-ibigroup May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do ES Lint rules apply to this repo? I know there are rules for a multiline ternary.

Datatools has its own eslint config, supplied by mastarm

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
Loading