question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add isISOMatch function

See original GitHub issue

Suggest 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:open
  • Created 2 years ago
  • Reactions:11
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Liam-Taitcommented, Oct 9, 2021

@lielfr This is just a feature suggestion atm. Suggest waiting for the maintainers to respond

cc: @tan75

1reaction
lielfrcommented, Dec 21, 2021

@klokar Thanks. Unfortunately I’ve been busy with uni stuff. Should’ve written about it sooner, sorry about that.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found