Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typedconverter

Package Overview
Dependencies
Maintainers
1
Versions
193
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typedconverter - npm Package Compare versions

Comparing version 1.0.0-beta.5 to 1.0.0-beta.6

32

lib/validation.js

@@ -11,2 +11,5 @@ "use strict";

exports.PartialValidator = PartialValidator;
// --------------------------------------------------------------------- //
// ----------------------------- DECORATORS ---------------------------- //
// --------------------------------------------------------------------- //
function createValidation(validator) {

@@ -24,2 +27,17 @@ return tinspector_1.decorateProperty({ type: "tc:validator", validator });

exports.partial = partial;
// --------------------------------------------------------------------- //
// ------------------------------ HELPERS ------------------------------ //
// --------------------------------------------------------------------- //
function isOptional(i) {
return i.decorators.find((x) => x.validator === OptionalValidator);
}
function isPartial(i) {
return i.parent && i.parent.decorators.find((x) => x.validator === PartialValidator);
}
function isEmpty(result) {
return (result.value === undefined || result.value === null) && result.issues === undefined;
}
// --------------------------------------------------------------------- //
// ------------------------------ VISITORS ----------------------------- //
// --------------------------------------------------------------------- //
/**

@@ -31,6 +49,3 @@ * When registered to the converter, this visitor will make all variable or properties required by default, except optional decorator added

const result = i.proceed();
const isEmpty = () => (result.value === undefined || result.value === null) && result.issues === undefined;
const isOptional = () => i.decorators.find((x) => x.validator === OptionalValidator);
const isPartial = () => i.parent && i.parent.decorators.find((x) => x.validator === PartialValidator);
if (isEmpty() && !isOptional() && !isPartial())
if (isEmpty(result) && !isOptional(i) && !isPartial(i))
return visitor_1.Result.error(i.path, `Required`);

@@ -48,4 +63,7 @@ else

const validators = getValidators(i);
if (validators.length > 0) {
const result = i.proceed();
const result = i.proceed();
//if empty then don't do any more validation
if (isEmpty(result) || validators.length === 0)
return result;
else {
const messages = [];

@@ -61,5 +79,3 @@ for (const validator of validators) {

}
else
return i.proceed();
}
exports.validatorVisitor = validatorVisitor;
{
"name": "typedconverter",
"version": "1.0.0-beta.5",
"version": "1.0.0-beta.6",
"description": "Convert object into classes match with TypeScript type annotation",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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