Socket
Socket
Sign inDemoInstall

validation.ts

Package Overview
Dependencies
1
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.21 to 0.0.22

6

commonjs/validation.d.ts

@@ -119,2 +119,8 @@ import { Result, Ok, Err, Option, None, Some } from 'space-lift';

export declare function literal<V extends Literal>(value: V): Validator<V>;
export declare function intersection<A, B>(a: Validator<A>, b: Validator<B>): Validator<A & B>;
export declare function intersection<A, B, C>(a: Validator<A>, b: Validator<B>, c: Validator<C>): Validator<A & B & C>;
export declare function intersection<A, B, C>(a: Validator<A>, b: Validator<B>, c: Validator<C>): Validator<A & B & C>;
export declare function intersection<A, B, C, D>(a: Validator<A>, b: Validator<B>, c: Validator<C>, d: Validator<D>): Validator<A & B & C & D>;
export declare function intersection<A, B, C, D, E>(a: Validator<A>, b: Validator<B>, c: Validator<C>, d: Validator<D>, e: Validator<E>): Validator<A & B & C & D & E>;
export declare function intersection<A, B, C, D, E, F>(a: Validator<A>, b: Validator<B>, c: Validator<C>, d: Validator<D>, e: Validator<E>, f: Validator<F>): Validator<A & B & C & D & E & F>;
export declare class UnionValidator<A> extends Validator<A> {

@@ -121,0 +127,0 @@ private validators;

38

commonjs/validation.js

@@ -296,3 +296,4 @@ "use strict";

if (validation.isOk()) {
validatedObject[key] = validation.get();
if (validation.get() !== undefined)
validatedObject[key] = validation.get();
}

@@ -408,2 +409,37 @@ else {

//--------------------------------------
// intersection
//--------------------------------------
var IntersectionValidator = /** @class */ (function (_super) {
__extends(IntersectionValidator, _super);
function IntersectionValidator(validators) {
var _this = _super.call(this) || this;
_this.validators = validators;
return _this;
}
IntersectionValidator.prototype.validate = function (v, config, c) {
if (config === void 0) { config = defaultConfig; }
if (c === void 0) { c = rootContext; }
var result = {};
for (var i = 0; i < this.validators.length; i++) {
var validation = this.validators[i].validate(v, config, c);
if (validation.isOk()) {
Object.assign(result, validation.get());
}
else {
return validation;
}
}
return success(result);
};
return IntersectionValidator;
}(Validator));
function intersection() {
var values = [];
for (var _i = 0; _i < arguments.length; _i++) {
values[_i] = arguments[_i];
}
return new IntersectionValidator(values);
}
exports.intersection = intersection;
//--------------------------------------
// union

@@ -410,0 +446,0 @@ //--------------------------------------

@@ -119,2 +119,8 @@ import { Result, Ok, Err, Option, None, Some } from 'space-lift';

export declare function literal<V extends Literal>(value: V): Validator<V>;
export declare function intersection<A, B>(a: Validator<A>, b: Validator<B>): Validator<A & B>;
export declare function intersection<A, B, C>(a: Validator<A>, b: Validator<B>, c: Validator<C>): Validator<A & B & C>;
export declare function intersection<A, B, C>(a: Validator<A>, b: Validator<B>, c: Validator<C>): Validator<A & B & C>;
export declare function intersection<A, B, C, D>(a: Validator<A>, b: Validator<B>, c: Validator<C>, d: Validator<D>): Validator<A & B & C & D>;
export declare function intersection<A, B, C, D, E>(a: Validator<A>, b: Validator<B>, c: Validator<C>, d: Validator<D>, e: Validator<E>): Validator<A & B & C & D & E>;
export declare function intersection<A, B, C, D, E, F>(a: Validator<A>, b: Validator<B>, c: Validator<C>, d: Validator<D>, e: Validator<E>, f: Validator<F>): Validator<A & B & C & D & E & F>;
export declare class UnionValidator<A> extends Validator<A> {

@@ -121,0 +127,0 @@ private validators;

@@ -285,3 +285,4 @@ var __extends = (this && this.__extends) || (function () {

if (validation.isOk()) {
validatedObject[key] = validation.get();
if (validation.get() !== undefined)
validatedObject[key] = validation.get();
}

@@ -393,2 +394,36 @@ else {

//--------------------------------------
// intersection
//--------------------------------------
var IntersectionValidator = /** @class */ (function (_super) {
__extends(IntersectionValidator, _super);
function IntersectionValidator(validators) {
var _this = _super.call(this) || this;
_this.validators = validators;
return _this;
}
IntersectionValidator.prototype.validate = function (v, config, c) {
if (config === void 0) { config = defaultConfig; }
if (c === void 0) { c = rootContext; }
var result = {};
for (var i = 0; i < this.validators.length; i++) {
var validation = this.validators[i].validate(v, config, c);
if (validation.isOk()) {
Object.assign(result, validation.get());
}
else {
return validation;
}
}
return success(result);
};
return IntersectionValidator;
}(Validator));
export function intersection() {
var values = [];
for (var _i = 0; _i < arguments.length; _i++) {
values[_i] = arguments[_i];
}
return new IntersectionValidator(values);
}
//--------------------------------------
// union

@@ -395,0 +430,0 @@ //--------------------------------------

2

package.json
{
"name": "validation.ts",
"version": "0.0.21",
"version": "0.0.22",
"description": "Validation for TypeScript",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc