Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
@helloclub/joi-luxon
Advanced tools
A Joi extension to automatically convert ISO date strings to Luxon DateTime objects
A Joi extension to automatically convert ISO date strings to Luxon DateTime objects
DateTime
objectsstartOf
or endOf
gt
, lt
, gte
or lte
#npm
npm install @helloclub/joi-luxon
#yarn
yarn add @helloclub/joi-luxon
import Joi from 'joi'
import JoiLuxon from '@helloclub/joi-luxon'
export default Joi.extend(JoiLuxon)
Validate a start and end date, setting the date to start and end of day respectively and validating that the end date is after the start date:
const schema = Joi.object({
startDate: Joi
.luxon()
.setZone(timezone)
.startOf('day'),
endDate: Joi
.luxon()
.setZone(timezone)
.endOf('day')
.gt(Joi.ref('startDate')),
})
Set the value to a given minimum date if it’s less than that:
const schema = Joi.object({
date: Joi
.luxon()
.required()
.min(Joi.ref('$minDate'))
})
const schema = Joi.object({
date: Joi
.luxon()
.required()
.min(new Date())
})
All available rules and helpers:
Joi
//Base validation and conversion to Luxon DateTime object
.luxon()
//Sets the timezone on the object
.setZone(timezone)
//Modified the DateTime instance to the start/end of the given period
.startOf(period)
.endOf(period)
//Validates silently against a minimum / maximum date
.min(date)
.max(date)
//Validate and throw errors if the date is less than or greater than a reference date
.lt(date)
.gt(date)
.lte(date)
.gte(date)
Please report any bugs, issues, suggestions and feature requests in the joi-luxon issue tracker.
This package is sponsored by Hello Club, an all-in-one club and membership management solution complete with booking system, automated membership renewals, online payments and integrated access and light control.
If you belong to any kind of club or membership based organisation, or if you know someone who helps run a club, please check us out!
(MIT License)
Copyright 2022-2023, Hello Club
FAQs
A Joi extension to automatically convert ISO date strings to Luxon DateTime objects
We found that @helloclub/joi-luxon 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.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.