Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
iso-datestring-validator
Advanced tools
The goal of the package is to provide lightweight tools for validating strings denotings dates and time. It includes ISO 8601 datestring validation, simple YYYY-MM-DD date validation and time validation in hh:mm:ss.fff format. See details in readme.
A simple package for validating strings denoting dates and time, including ISO 8601 format. The package provides the following functions:
npm i --save iso-datestring-validator
or
yarn add iso-datestring-validator
const isoDatestringValidator = require("iso-datestring-validator");
Pass a YYYY-MM-DD date string to the isValidDate function to check it. To validate dates that use a custom digit separator, pass it as the second argument.
const isoDatestringValidator = require("iso-datestring-validator");
isoDatestringValidator.isValidDate("2019-01-31");
// true
isoDatestringValidator.isValidDate("20190131");
// false, no custom digit separator provided, hyphen separator not found in the string
isoDatestringValidator.isValidDate("20190131", '');
// true
isoDatestringValidator.isValidDate("2019/01/31", '/');
// true
Time string in HH:mm:ss.fff format can be validated with the isValidTime function. Seconds and fractions are optional. However, if using fractions min number of numbers is 1 and max is 9.
const isoDatestringValidator = require("iso-datestring-validator");
isoDatestringValidator.isValidTime("13:00");
// true
isoDatestringValidator.isValidTime("13:00:00");
// true
isoDatestringValidator.isValidTime("13:00:00.000000000");
// true
These are validated by the isValidYearMonth function. Rules same as in the previous case: a string YYYY-MM and a custom digit separator if required.
const isoDatestringValidator = require("iso-datestring-validator");
isoDatestringValidator.isValidYearMonth("2019/01", '/');
// true
isoDatestringValidator.isValidYearMonth("2019-01");
// true
Pass a string to isValidISODateString to see if it is valid.
const isoDatestringValidator = require("iso-datestring-validator");
isoDatestringValidator.isValidISODateString('2019-07-09T15:03:36.000+00:00');
// true
isoDatestringValidator.isValidISODateString('20190709T150336Z');
// true
That's all about this package. Have fun, feel free to contribute with some test :]
FAQs
The goal of the package is to provide lightweight tools for validating strings denotings dates and time. It includes ISO 8601 datestring validation, simple YYYY-MM-DD date validation and time validation in hh:mm:ss.fff format. See details in readme.
The npm package iso-datestring-validator receives a total of 36,637 weekly downloads. As such, iso-datestring-validator popularity was classified as popular.
We found that iso-datestring-validator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.