Use validate() to run structural and data checks before import/persistence.
import { Ofx } from 'ofx-data-extractor'
const report = new Ofx(ofxText, { parserMode: 'lenient' }).validate()type ValidationReport = {
isValid: boolean
warnings: OfxDiagnostic[]
errors: OfxDiagnostic[]
stats: {
totalTransactions: number
bankTransactions: number
creditCardTransactions: number
duplicatedFitIds: number
}
}- Missing OFX block
- Missing transactions
- Missing FITID
- Duplicated FITID
- Invalid amount
- Invalid date (
DTPOSTED)
errorsimpactisValid(isValidisfalsewhen any error exists)warningsdo not invalidate the report by default
If your domain requires stricter behavior (for example invalid dates as hard failure), apply an application-level rule on top of warnings.