Browse plugins

plugin-validate-date

A Flatfile plugin for normalizing date formats

Install
npm i @flatfile/plugin-validate-date
Source:
View source
Package:
@flatfile/plugin-validate-date 113 installs
Dependencies
@flatfile/plugin-record-hook@^1.7.1, chrono-node@^2.7.7 (+1 more)

The @flatfile/plugin-validate-date plugin provides date format normalization functionality for Flatfile. It detects various date formats and converts them to a specified output format, supporting multiple fields and locales.

Event Type: listener.on('commit:created')

Parameters

config.sheetSlug - string - default: ** - (optional)

The sheetSlug parameter is the slug of the sheet to apply the normalizer to. If not provided, it will apply to all sheets.

config.dateFields - string[]

The dateFields parameter is an array of field names that contain date values to be normalized.

config.outputFormat - string

The outputFormat parameter specifies the desired output format for the normalized dates.

config.includeTime - boolean

The includeTime parameter determines whether to include time in the normalized output.

Usage

npm install @flatfile/plugin-validate-date

Import

import { validateDate } from '@flatfile/plugin-validate-date'

Example Usage

This example sets up the date format normalizer for the "contacts" sheet, normalizing the "birthdate" and "registration_date" fields to the "MM/DD/YYYY" format.

import { FlatfileListener } from '@flatfile/listener'
import { validateDate } from '@flatfile/plugin-validate-date'

export default function (listener: FlatfileListener) {
  listener.use(
    validateDate({
      sheetSlug: 'contacts',
      dateFields: ['birthdate', 'registration_date'],
      outputFormat: 'MM/DD/YYYY',
      includeTime: false
    })
  )

  // ... rest of your Flatfile listener configuration
}