New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

backk-frontend-utils

Package Overview
Dependencies
Maintainers
1
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backk-frontend-utils - npm Package Compare versions

Comparing version 1.0.99 to 1.0.100

58

lib/decorators/typeproperty/IsTimestampBetween.js

@@ -5,4 +5,43 @@ import { registerDecorator } from 'cv-pksilen';

import isoWeek from 'dayjs/plugin/isoWeek';
import isLeapYear from 'dayjs/plugin/isLeapYear';
dayjs.extend(isBetween);
dayjs.extend(isoWeek);
dayjs.extend(isLeapYear);
const minValues = {
year: 1970,
month: 0,
date: 1,
hour: 0,
minute: 0,
};
const maxValues = {
year: 9999,
month: 11,
hour: 23,
minute: 59,
};
function getMaxDate(timestamp) {
switch (timestamp.month()) {
case 0:
case 2:
case 4:
case 6:
case 7:
case 9:
case 11:
return 31;
case 3:
case 5:
case 8:
case 10:
return 30;
case 1:
if (timestamp.isLeapYear()) {
return 29;
}
return 28;
default:
throw new Error('Invalid month');
}
}
export default function IsTimestampBetween(unit, startValue, endValue, validationOptions) {

@@ -23,4 +62,21 @@ return function (object, propertyName) {

}
return date.isBetween(startValue, endValue, unit);
let startTimestamp = dayjs();
let endTimestamp = dayjs();
startTimestamp = startTimestamp.set(unit, startValue);
endTimestamp = endTimestamp.set(unit, endValue);
['year', 'month', 'date', 'hour', 'minute'].forEach((u) => {
if (u !== unit) {
startTimestamp = startTimestamp.set(unit, minValues[unit]);
endTimestamp = endTimestamp.set(unit, unit === 'date' ? getMaxDate(endTimestamp) : maxValues[unit]);
}
});
return date.isBetween(startTimestamp, endTimestamp, unit);
},
defaultMessage: () => propertyName +
' must be a timestamp where ' +
unit +
' is between ' +
startValue +
' and ' +
endValue,
},

@@ -27,0 +83,0 @@ });

2

package.json
{
"name": "backk-frontend-utils",
"version": "1.0.99",
"version": "1.0.100",
"description": "Web frontend utils for Backk microservices",

@@ -5,0 +5,0 @@ "author": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc