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

@finnair/v-validation

Package Overview
Dependencies
Maintainers
4
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@finnair/v-validation - npm Package Compare versions

Comparing version 3.0.0-alpha.0 to 3.0.0-alpha.1

dist/scrap.d.ts

16

CHANGELOG.md

@@ -6,2 +6,18 @@ # Change Log

# [3.0.0-alpha.1](https://github.com/finnair/v-validation/compare/v2.0.0...v3.0.0-alpha.1) (2022-09-26)
### Features
* Use SyncPromise also in schema and luxon ([792fbb4](https://github.com/finnair/v-validation/commit/792fbb4c78d07ea085d669312fef5e44e7a397fd))
### Performance Improvements
* Optimize loops ([8c5c915](https://github.com/finnair/v-validation/commit/8c5c915794fb39ab6fd41ec7d3ac4e4f028ed7fa))
# [3.0.0-alpha.0](https://github.com/finnair/v-validation/compare/v2.0.0...v3.0.0-alpha.0) (2022-09-26)

@@ -8,0 +24,0 @@

2

dist/schema.d.ts

@@ -33,3 +33,3 @@ import { Validator, ValidationContext, ValidationResult, ObjectValidator, PropertyModel, MapEntryModel, Violation } from './validators';

export declare class SchemaValidator extends Validator {
private readonly discriminator;
readonly discriminator: Discriminator;
private readonly proxies;

@@ -36,0 +36,0 @@ private readonly validators;

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

this.name = name;
Object.freeze(this);
}

@@ -37,2 +38,4 @@ validatePath(value, path, ctx) {

this.compileSchema(schema.models, new Set());
Object.freeze(this.validators);
Object.freeze(this);
}

@@ -39,0 +42,0 @@ validatePath(value, path, ctx) {

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

};
Object.freeze(V);
exports.default = V;

@@ -186,8 +186,9 @@ import { Path } from '@finnair/path';

export declare class ObjectValidator extends Validator {
private readonly properties;
private readonly localProperties;
private readonly additionalProperties;
readonly model: ObjectModel;
readonly properties: Properties;
readonly localProperties: Properties;
readonly additionalProperties: MapEntryValidator[];
readonly parentValidators: ObjectValidator[];
readonly nextValidator: undefined | Validator;
private readonly localNextValidator;
readonly localNextValidator: undefined | Validator;
constructor(model: ObjectModel);

@@ -213,13 +214,13 @@ validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;

export declare class ArrayValidator extends Validator {
private readonly items;
constructor(items: Validator);
readonly itemsValidator: Validator;
constructor(itemsValidator: Validator);
validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;
}
export declare class ArrayNormalizer extends ArrayValidator {
constructor(items: Validator);
constructor(itemsValidator: Validator);
validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;
}
export declare class NextValidator extends Validator {
private readonly firstValidator;
private readonly nextValidator;
readonly firstValidator: Validator;
readonly nextValidator: Validator;
constructor(firstValidator: Validator, nextValidator: Validator);

@@ -229,3 +230,3 @@ validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;

export declare class CheckValidator extends Validator {
private readonly validator;
readonly validator: Validator;
constructor(validator: Validator);

@@ -235,8 +236,8 @@ validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;

export declare class CompositionValidator extends Validator {
private readonly validators;
constructor(validators: Validator[]);
readonly validators: Validator[];
constructor(validators: Validator | Validator[]);
validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;
}
export declare class OneOfValidator extends Validator {
private readonly validators;
readonly validators: Validator[];
constructor(validators: Validator[]);

@@ -246,3 +247,3 @@ validatePath(value: any, path: Path, ctx: ValidationContext): Promise<ValidationResult>;

export declare class AnyOfValidator extends Validator {
private readonly validators;
readonly validators: Validator[];
constructor(validators: Validator[]);

@@ -252,4 +253,4 @@ validatePath(value: any, path: Path, ctx: ValidationContext): Promise<ValidationResult>;

export declare class IfValidator extends Validator {
private readonly conditionals;
private readonly elseValidator?;
readonly conditionals: Conditional[];
readonly elseValidator?: Validator | undefined;
constructor(conditionals: Conditional[], elseValidator?: Validator | undefined);

@@ -266,4 +267,4 @@ validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;

export declare class WhenGroupValidator extends Validator {
private readonly whenGroups;
private readonly otherwiseValidator?;
readonly whenGroups: WhenGroup[];
readonly otherwiseValidator?: Validator | undefined;
constructor(whenGroups: WhenGroup[], otherwiseValidator?: Validator | undefined);

@@ -280,5 +281,5 @@ validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;

export declare class MapValidator extends Validator {
private readonly keys;
private readonly values;
private readonly jsonSafeMap;
readonly keys: Validator;
readonly values: Validator;
readonly jsonSafeMap: boolean;
constructor(keys: Validator, values: Validator, jsonSafeMap: boolean);

@@ -330,4 +331,4 @@ validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;

export declare class BooleanNormalizer extends Validator {
private readonly truePattern;
private readonly falsePattern;
readonly truePattern: RegExp;
readonly falsePattern: RegExp;
constructor(truePattern: RegExp, falsePattern: RegExp);

@@ -342,3 +343,3 @@ validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;

export declare class NumberValidator extends Validator {
protected readonly format: NumberFormat;
readonly format: NumberFormat;
constructor(format: NumberFormat);

@@ -353,4 +354,4 @@ validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;

export declare class MinValidator extends Validator {
private readonly min;
private readonly inclusive;
readonly min: number;
readonly inclusive: boolean;
constructor(min: number, inclusive: boolean);

@@ -360,4 +361,4 @@ validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;

export declare class MaxValidator extends Validator {
private readonly max;
private readonly inclusive;
readonly max: number;
readonly inclusive: boolean;
constructor(max: number, inclusive: boolean);

@@ -367,4 +368,4 @@ validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;

export declare class EnumValidator extends Validator {
private readonly enumType;
private readonly name;
readonly enumType: object;
readonly name: string;
constructor(enumType: object, name: string);

@@ -374,5 +375,5 @@ validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;

export declare class AssertTrueValidator extends Validator {
private readonly type;
private readonly path?;
private fn;
readonly type: string;
readonly path?: Path | undefined;
fn: AssertTrue;
constructor(fn: AssertTrue, type: string, path?: Path | undefined);

@@ -382,3 +383,3 @@ validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;

export declare class HasValueValidator extends Validator {
private readonly expectedValue;
readonly expectedValue: any;
constructor(expectedValue: any);

@@ -389,3 +390,3 @@ validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;

export declare class AllOfValidator extends Validator {
private readonly validators;
readonly validators: Validator[];
constructor(validators: Validator[]);

@@ -392,0 +393,0 @@ validatePath(value: any, path: Path, ctx: ValidationContext): PromiseLike<ValidationResult>;

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

this.value = value;
Object.freeze(this.violations);
}

@@ -240,2 +241,3 @@ isSuccess() {

}
Object.freeze(this.allIncluded);
}

@@ -372,2 +374,3 @@ includes(groupOrName) {

this.fn = fn;
Object.freeze(this);
}

@@ -398,2 +401,3 @@ validatePath(value, path, ctx) {

super();
this.model = model;
let properties = {};

@@ -425,2 +429,7 @@ let additionalProperties = [];

this.localNextValidator = model.localNext;
Object.freeze(this.properties);
Object.freeze(this.localProperties);
Object.freeze(this.additionalProperties);
Object.freeze(this.parentValidators);
Object.freeze(this);
}

@@ -536,2 +545,3 @@ validatePath(value, path, ctx) {

this.property = property;
Object.freeze(this);
}

@@ -555,2 +565,3 @@ validatePath(value, path, ctx) {

this.valueValidator = maybeAllOfValidator(entryModel.values);
Object.freeze(this);
}

@@ -560,5 +571,6 @@ }

class ArrayValidator extends Validator {
constructor(items) {
constructor(itemsValidator) {
super();
this.items = items;
this.itemsValidator = itemsValidator;
Object.freeze(this);
}

@@ -581,3 +593,3 @@ validatePath(value, path, ctx) {

const item = value[i];
promises[i] = this.items.validatePath(item, path.index(i), ctx).then(result => {
promises[i] = this.itemsValidator.validatePath(item, path.index(i), ctx).then(result => {
if (result.isSuccess()) {

@@ -602,4 +614,4 @@ convertedArray[i] = result.getValue();

class ArrayNormalizer extends ArrayValidator {
constructor(items) {
super(items);
constructor(itemsValidator) {
super(itemsValidator);
}

@@ -622,2 +634,3 @@ validatePath(value, path, ctx) {

this.nextValidator = nextValidator;
Object.freeze(this);
}

@@ -643,2 +656,3 @@ validatePath(value, path, ctx) {

this.validator = validator;
Object.freeze(this);
}

@@ -658,4 +672,5 @@ validatePath(value, path, ctx) {

super();
this.validators = [];
this.validators = this.validators.concat(validators);
this.validators = [].concat(validators);
Object.freeze(this.validators);
Object.freeze(this);
}

@@ -683,2 +698,4 @@ validatePath(value, path, ctx) {

this.validators = validators;
Object.freeze(this.validators);
Object.freeze(this);
}

@@ -712,2 +729,4 @@ validatePath(value, path, ctx) {

this.validators = validators;
Object.freeze(this.validators);
Object.freeze(this);
}

@@ -733,2 +752,4 @@ validatePath(value, path, ctx) {

this.elseValidator = elseValidator;
Object.freeze(this.conditionals);
Object.freeze(this);
}

@@ -765,2 +786,4 @@ validatePath(value, path, ctx) {

this.validator = maybeAllOfValidator(allOf);
Object.freeze(this.validator);
Object.freeze(this);
}

@@ -774,2 +797,4 @@ }

this.otherwiseValidator = otherwiseValidator;
Object.freeze(this.whenGroups);
Object.freeze(this);
}

@@ -808,2 +833,3 @@ validatePath(value, path, ctx) {

this.validator = maybeAllOfValidator(allOf);
Object.freeze(this);
}

@@ -818,2 +844,3 @@ }

this.jsonSafeMap = jsonSafeMap;
Object.freeze(this);
}

@@ -979,2 +1006,3 @@ validatePath(value, path, ctx) {

}
Object.freeze(this);
}

@@ -1031,2 +1059,3 @@ validatePath(value, path, ctx) {

this.falsePattern = falsePattern;
Object.freeze(this);
}

@@ -1072,2 +1101,3 @@ validatePath(value, path, ctx) {

this.format = format;
Object.freeze(this);
}

@@ -1125,2 +1155,3 @@ validatePath(value, path, ctx) {

this.inclusive = inclusive;
Object.freeze(this);
}

@@ -1151,2 +1182,3 @@ validatePath(value, path, ctx) {

this.inclusive = inclusive;
Object.freeze(this);
}

@@ -1177,2 +1209,3 @@ validatePath(value, path, ctx) {

this.name = name;
Object.freeze(this);
}

@@ -1197,2 +1230,3 @@ validatePath(value, path, ctx) {

this.fn = fn;
Object.freeze(this);
}

@@ -1211,2 +1245,3 @@ validatePath(value, path, ctx) {

this.expectedValue = expectedValue;
Object.freeze(this);
}

@@ -1238,2 +1273,4 @@ validatePath(value, path, ctx) {

this.validators = [].concat(validators);
Object.freeze(this.validators);
Object.freeze(this);
}

@@ -1240,0 +1277,0 @@ validatePath(value, path, ctx) {

{
"name": "@finnair/v-validation",
"version": "3.0.0-alpha.0",
"version": "3.0.0-alpha.1",
"private": false,

@@ -27,3 +27,3 @@ "description": "V-validation core package",

"dependencies": {
"@finnair/path": "^2.0.0",
"@finnair/path": "^3.0.0-alpha.1",
"@types/deep-equal": "1.0.1",

@@ -34,3 +34,3 @@ "@types/uuid-validate": "0.0.1",

},
"gitHead": "f41f76dbe0365314dc15c07d3db2ad5a7b5e4109"
"gitHead": "34e2b0697aaee247e03b7a65d677c7b766a7fbca"
}

@@ -72,3 +72,3 @@ ![CI](https://github.com/finnair/v-validation/workflows/CI/badge.svg?branch=master)

Validators are immutable objects/functions that can be combined to form more complex models.
Validators are effectively immutable objects/functions that can be combined to form more complex models.

@@ -75,0 +75,0 @@ ```typescript

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