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

@travetto/schema

Package Overview
Dependencies
Maintainers
0
Versions
329
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/schema - npm Package Compare versions

Comparing version 5.0.10 to 5.0.11

6

package.json
{
"name": "@travetto/schema",
"version": "5.0.10",
"version": "5.0.11",
"description": "Data type registry for runtime validation, reflection and binding.",

@@ -30,6 +30,6 @@ "keywords": [

"dependencies": {
"@travetto/registry": "^5.0.10"
"@travetto/registry": "^5.0.11"
},
"peerDependencies": {
"@travetto/transformer": "^5.0.8"
"@travetto/transformer": "^5.0.9"
},

@@ -36,0 +36,0 @@ "peerDependenciesMeta": {

@@ -11,3 +11,3 @@ import { Class, AppError } from '@travetto/runtime';

constructor(errors: ValidationError[]) {
super('Validation errors have occurred', 'data', { errors });
super('Validation errors have occurred', { category: 'data', details: { errors } });
}

@@ -22,3 +22,3 @@ }

constructor(cls: Class | string, type: string) {
super(`Expected ${typeof cls === 'string' ? cls : cls.name} but found ${type}`, 'data');
super(`Expected ${typeof cls === 'string' ? cls : cls.name} but found ${type}`, { category: 'data' });
}

@@ -25,0 +25,0 @@ }

@@ -11,4 +11,4 @@ /**

match: '{path} should match {re}',
min: '{path} is not greater than ({n})',
max: '{path} is bigger than ({n})',
min: '{path} is less than ({n})',
max: '{path} is greater than ({n})',
telephone: '{path} is not a valid phone number',

@@ -15,0 +15,0 @@ url: '{path} is not a valid url',

@@ -115,28 +115,9 @@ import { castKey, castTo, Class, ClassInstance, TypedObject } from '@travetto/runtime';

static #validateRange(field: FieldConfig, key: 'min' | 'max', value: string | number | Date): boolean {
const f = field[key]!;
const valueNum = (typeof value === 'string') ?
(field.type === Date ? Date.parse(value) : parseInt(value, 10)) :
(value instanceof Date ? value.getTime() : value);
const f = field[key]!;
const fn = f.n;
if (typeof fn === 'number') {
if (typeof value === 'string') {
value = parseInt(value, 10);
}
if (field.type === Date) {
value = new Date(value);
}
const valN = typeof value === 'number' ? value : value.getTime();
if (key === 'min' && valN < fn || key === 'max' && valN > fn) {
return true;
}
} else {
const date = fn.getTime();
if (typeof value === 'string') {
value = Date.parse(value);
} else if (value instanceof Date) {
value = value.getTime();
}
if (key === 'min' && value < date || key === 'max' && value > date) {
return true;
}
}
return false;
const boundary = (typeof f.n === 'number' ? f.n : f.n.getTime());
return key === 'min' ? valueNum < boundary : valueNum > boundary;
}

@@ -318,5 +299,5 @@

if (err instanceof ValidationResultError) { // Don't check required fields
const errs = err.details!.errors.filter(x => x.kind !== 'required');
const errs = err.details.errors.filter(x => x.kind !== 'required');
if (errs.length) {
err.details!.errors = errs;
err.details.errors = errs;
throw err;

@@ -323,0 +304,0 @@ }

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