Add isISOMatch function
See original GitHub issueSuggest adding isISOMatch
function, used for validating a date string is in ISO 8601 format.
Options similar to the output of formatISO
would be used to further restrict the validateion
The usages of this function is similar to the isMatch
function, except where stringent ISO formatting should be used.
In my personal use case I would use the
isISOMatch(dateString, { representation: 'date' })
to validate ISO date strings as parameters to an API.
This is in line with other ISO specific functions, such as:
parse
->parseISO
format
->formatISO
formatDuration
->formatISODuration
In line with formatDuration
-> formatISODuration
, it is more natural to go with
isISOMatch
than isMatchISO
another option could be isISO
though I believe this would cause more confusion and is not in line with the existing api.
Usage
// CommonJS
var isISOMatch = require('date-fns/isISOMatch')
// ES 2015
import isISOMatch from 'date-fns/isISOMatch'
// ESM
import { isISOMatch } from 'date-fns'
Syntax
isISOMatch(dateString, [options]);
Arguments
Name | Type | Description |
---|---|---|
dateString | String | The date string to verify |
options | Object | An object with options |
Options
Name | Type | Description |
---|---|---|
representation (optional, default=‘complete’) |
‘complete’ | ‘date’ | ‘time’ | match date, time with time zone, or both |
Returns
Type | Description |
---|---|
Boolean | is the date string an ISO date string |
Issue Analytics
- State:
- Created 2 years ago
- Reactions:11
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Tutorial: Adding a custom function
In this tutorial, you are writing a custom function that you package and store in a GitHub repository. You are testing the function...
Read more >Is there a way to add a function to an elixir module ...
I have run into a problem of tracking which mock function corresponds to which test. I added a mock module for the test...
Read more >[Addition]: Selfwitnessing cluster (COTX 21 HS) - Helium/Denylist
Add isISOMatch function, 8, 2021-10-06, 2022-09-25. Protobuf unmarshalling, 2, 2020-04-09, 2022-06-18. "Invalid Markup" error immediately disappears when ...
Read more >HiSense Air Conditioners issue - Home-Assistant/Core
Add isISOMatch function, 8, 2021-10-06, 2022-12-09. Confusing error message when using `..` on a non-existing record, 2, 2022-10-28 ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@lielfr This is just a feature suggestion atm. Suggest waiting for the maintainers to respond
cc: @tan75
@klokar Thanks. Unfortunately I’ve been busy with uni stuff. Should’ve written about it sooner, sorry about that.