Skip to content

Commit

Permalink
feat: fix some Readmes (#677)
Browse files Browse the repository at this point in the history
* feat: fix date Readme

* feat: fix number readme

* feat: fix test

* Update validate/date/README.md

* chore: update READMEs

---------

Co-authored-by: Carl Brugger <[email protected]>
  • Loading branch information
bangarang and carlbrugger authored Oct 22, 2024
1 parent 37af018 commit 77df987
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .changeset/four-peas-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@flatfile/plugin-validate-number': patch
'@flatfile/plugin-validate-date': patch
---

Update READMEs
11 changes: 7 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions validate/date/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ The `outputFormat` parameter specifies the desired output format for the normali
#### `config.includeTime` - `boolean`
The `includeTime` parameter determines whether to include time in the normalized output.

#### `config.locale` - `string` - (optional)
The `locale` parameter specifies the locale to use for date parsing. Currently, only 'en-US' is supported.

## Usage

```bash install
Expand All @@ -45,12 +48,16 @@ export default function (listener: FlatfileListener) {
listener.use(
validateDate({
sheetSlug: 'contacts',
dateFields: ['birthdate', 'registration_date'],
outputFormat: 'MM/DD/YYYY',
dateFields: ['birth_date', 'registration_date'],
outputFormat: 'MM/dd/yyyy',
includeTime: false
})
)

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

## Notes

- The plugin uses the `chrono-node` library for parsing dates, which supports a wide range of date formats.
- If a date cannot be parsed, the plugin will add an error message to the record for that field.
- The `locale` parameter is included in the configuration interface but is not currently used in the implementation. The plugin defaults to using the 'en-US' locale.
4 changes: 2 additions & 2 deletions validate/date/src/validate.date.plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ describe('NormalizeDate e2e', () => {

const records = await getRecords(sheetId)

expect(records[0].values['date'].messages.length).toBeGreaterThan(0)
expect(records[0].values['date'].messages[0].message).toContain(
expect(records[0].values['date'].messages?.length).toBeGreaterThan(0)
expect(records[0].values['date'].messages?.[0].message).toContain(
'Unable to parse date string'
)
})
Expand Down
5 changes: 4 additions & 1 deletion validate/number/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ listener.use(
thousandsSeparator: ',',
decimalPoint: '.',
specialTypes: ['even'],
round: true
round: true,
fields: ['numberField']
})
);
```
Expand All @@ -71,6 +72,8 @@ The `validateNumber` accepts a configuration object with the following options:
- `specialTypes`: Array of special number types to validate ('prime', 'even', 'odd')
- `round`: Round the number to the nearest integer
- `truncate`: Truncate the decimal part of the number
- `fields`: Array of field names to apply the validation to
- `sheetSlug`: The slug of the sheet to apply the validation to

## Behavior

Expand Down

0 comments on commit 77df987

Please sign in to comment.