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

modelsafe

Package Overview
Dependencies
Maintainers
3
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

modelsafe - npm Package Compare versions

Comparing version 1.0.0-alpha.9 to 1.0.0-alpha.10

5

CHANGELOG.md

@@ -0,1 +1,6 @@

# 1.0.0-alpha.10
* [FIX] reject invalid dates in date validator
* [FIX] deserialize ISO strings into Date objects
# 1.0.0-alpha.9

@@ -2,0 +7,0 @@

4

dist/attribute.js

@@ -179,3 +179,3 @@ "use strict";

return __generator(this, function (_a) {
if (!_.isDate(value)) {
if (!_.isDate(value) || isNaN(value.getTime())) {
throw new validation_1.PropertyValidationError('attribute.time', 'Not a time');

@@ -193,3 +193,3 @@ }

return __generator(this, function (_a) {
if (!_.isDate(value)) {
if (!_.isDate(value) || isNaN(value.getTime())) {
throw new validation_1.PropertyValidationError('attribute.date', 'Not a date');

@@ -196,0 +196,0 @@ }

@@ -58,2 +58,3 @@ "use strict";

var _ = require("lodash");
var attribute_1 = require("./attribute");
var association_1 = require("./association");

@@ -135,2 +136,8 @@ var metadata_1 = require("./metadata");

instance = new this(_.pick(data, Object.keys(attrs)), { defaults: false });
// Convert date ISO string into Date object
Object.keys(attrs).forEach(function (key) {
if (attrs[key].type.type === attribute_1.DATE.type && typeof (instance[key]) === 'string') {
instance[key] = new Date(instance[key]);
}
});
if (!assocOptions.associations) return [3 /*break*/, 4];

@@ -137,0 +144,0 @@ _loop_1 = function (key) {

{
"name": "modelsafe",
"version": "1.0.0-alpha.9",
"version": "1.0.0-alpha.10",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "bugs": "https://github.com/creativecuriositystudio/modelsafe/issues",

@@ -167,3 +167,3 @@ /** Contains the attribute types. */

export const TIME = buildAttributeType(InternalAttributeType.TIME, async (_path: string, value: any) => {
if (!_.isDate(value)) {
if (!_.isDate(value) || isNaN(value.getTime())) {
throw new PropertyValidationError('attribute.time', 'Not a time');

@@ -179,3 +179,3 @@ }

export const DATE = buildAttributeType(InternalAttributeType.DATE, async (_path: string, value: any) => {
if (!_.isDate(value)) {
if (!_.isDate(value) || isNaN(value.getTime())) {
throw new PropertyValidationError('attribute.date', 'Not a date');

@@ -182,0 +182,0 @@ }

/** Contains the model classes and decorators. */
import * as _ from 'lodash';
import { DATE } from './attribute';
import { isLazyLoad, HAS_MANY, BELONGS_TO_MANY } from './association';

@@ -138,2 +139,9 @@ import { getAttributes, getAttributeValidations, getAssociations } from './metadata';

// Convert date ISO string into Date object
Object.keys(attrs).forEach(key => {
if (attrs[key].type.type === DATE.type && typeof (instance[key]) === 'string') {
instance[key] = new Date(instance[key]);
}
});
if (assocOptions.associations) {

@@ -140,0 +148,0 @@ // Call deserialization methods for associations to populate deserialized association data

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