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
44
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 0.9.1 to 1.0.0

8

CHANGELOG.md

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

# [1.0.0](https://github.com/finnair/v-validation/compare/v0.9.1...v1.0.0) (2022-01-20)
**Note:** Version bump only for package @finnair/v-validation
## [0.9.1](https://github.com/finnair/v-validation/compare/v0.9.0...v0.9.1) (2020-12-07)

@@ -8,0 +16,0 @@

8

dist/index.js

@@ -10,7 +10,11 @@ "use strict";

var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.V = void 0;
var V_1 = require("./V");
Object.defineProperty(exports, "V", { enumerable: true, get: function () { return V_1.default; } });
Object.defineProperty(exports, "V", { enumerable: true, get: function () { return __importDefault(V_1).default; } });
__exportStar(require("./validators"), exports);

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

return __awaiter(this, void 0, void 0, function* () {
if (validators_1.isNullOrUndefined(value)) {
if ((0, validators_1.isNullOrUndefined)(value)) {
return ctx.failure(validators_1.defaultViolations.notNull(path), value);

@@ -60,3 +60,3 @@ }

let typePath = path;
if (validators_1.isString(this.discriminator)) {
if ((0, validators_1.isString)(this.discriminator)) {
type = value[this.discriminator];

@@ -129,3 +129,3 @@ typePath = path.property(this.discriminator);

const localProperties = classModel.localProperties || {};
if (validators_1.isString(this.discriminator)) {
if ((0, validators_1.isString)(this.discriminator)) {
const discriminatorProperty = this.discriminator;

@@ -156,3 +156,3 @@ if (!localProperties[discriminatorProperty]) {

let parent;
if (validators_1.isString(nameOrValidator)) {
if ((0, validators_1.isString)(nameOrValidator)) {
parent = this.compileClass(nameOrValidator, models, seen);

@@ -159,0 +159,0 @@ }

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

const validators_1 = require("./validators");
const ignoreValidator = new validators_1.IgnoreValidator(), anyValidator = new validators_1.AnyValidator(), stringValidator = new validators_1.StringValidator(), toStringValidator = new validators_1.StringNormalizer(), notNullValidator = new validators_1.NotNullOrUndefinedValidator(), nullOrUndefinedValidator = new validators_1.IsNullOrUndefinedValidator(), notEmptyValidator = new validators_1.NotEmptyValidator(), notBlankValidator = new validators_1.NotBlankValidator(), emptyToNullValidator = new validators_1.ValueMapper(val => (validators_1.isNullOrUndefined(val) || val === '' ? null : val)), emptyToUndefinedValidator = new validators_1.ValueMapper(val => (validators_1.isNullOrUndefined(val) || val === '' ? undefined : val)), undefinedToNullValidator = new validators_1.ValueMapper(val => (val === undefined ? null : val)), booleanValidator = new validators_1.BooleanValidator(), numberValidator = new validators_1.NumberValidator(validators_1.NumberFormat.number), toNumberValidator = new validators_1.NumberNormalizer(validators_1.NumberFormat.number), integerValidator = new validators_1.NumberValidator(validators_1.NumberFormat.integer), toIntegerValidator = new validators_1.NumberNormalizer(validators_1.NumberFormat.integer), dateValidator = new validators_1.DateValidator(validators_1.ValidatorType.Date);
const ignoreValidator = new validators_1.IgnoreValidator(), anyValidator = new validators_1.AnyValidator(), stringValidator = new validators_1.StringValidator(), toStringValidator = new validators_1.StringNormalizer(), notNullValidator = new validators_1.NotNullOrUndefinedValidator(), nullOrUndefinedValidator = new validators_1.IsNullOrUndefinedValidator(), notEmptyValidator = new validators_1.NotEmptyValidator(), notBlankValidator = new validators_1.NotBlankValidator(), emptyToNullValidator = new validators_1.ValueMapper(val => ((0, validators_1.isNullOrUndefined)(val) || val === '' ? null : val)), emptyToUndefinedValidator = new validators_1.ValueMapper(val => ((0, validators_1.isNullOrUndefined)(val) || val === '' ? undefined : val)), undefinedToNullValidator = new validators_1.ValueMapper(val => (val === undefined ? null : val)), booleanValidator = new validators_1.BooleanValidator(), numberValidator = new validators_1.NumberValidator(validators_1.NumberFormat.number), toNumberValidator = new validators_1.NumberNormalizer(validators_1.NumberFormat.number), integerValidator = new validators_1.NumberValidator(validators_1.NumberFormat.integer), toIntegerValidator = new validators_1.NumberNormalizer(validators_1.NumberFormat.integer), dateValidator = new validators_1.DateValidator(validators_1.ValidatorType.Date);
const V = {

@@ -16,3 +16,3 @@ fn: (fn, type) => new validators_1.ValidatorFnWrapper(fn, type),

any: () => anyValidator,
check: (...allOf) => new validators_1.CheckValidator(validators_1.maybeAllOfValidator(allOf)),
check: (...allOf) => new validators_1.CheckValidator((0, validators_1.maybeAllOfValidator)(allOf)),
optional: (type, ...allOf) => new validators_1.OptionalValidator(type, allOf),

@@ -31,4 +31,4 @@ required: (type, ...allOf) => new validators_1.NotNullOrUndefinedValidator().next(type).next(...allOf),

undefinedToNull: () => undefinedToNullValidator,
emptyTo: (defaultValue) => new validators_1.ValueMapper(val => (validators_1.isNullOrUndefined(val) || val === '' ? defaultValue : val)),
uuid: (version) => new validators_1.AssertTrueValidator(value => !validators_1.isNullOrUndefined(value) && uuid_validate_1.default(value, version), 'UUID'),
emptyTo: (defaultValue) => new validators_1.ValueMapper(val => ((0, validators_1.isNullOrUndefined)(val) || val === '' ? defaultValue : val)),
uuid: (version) => new validators_1.AssertTrueValidator(value => !(0, validators_1.isNullOrUndefined)(value) && (0, uuid_validate_1.default)(value, version), 'UUID'),
pattern: (pattern, flags) => new validators_1.PatternValidator(pattern, flags),

@@ -51,5 +51,5 @@ toPattern: (pattern, flags) => new validators_1.PatternNormalizer(pattern, flags),

toMapType: (keys, values) => new validators_1.MapNormalizer(keys, values),
nullTo: (defaultValue) => new validators_1.ValueMapper(value => (validators_1.isNullOrUndefined(value) ? defaultValue : value)),
array: (...items) => new validators_1.ArrayValidator(validators_1.maybeAllOfValidator(items)),
toArray: (...items) => new validators_1.ArrayNormalizer(validators_1.maybeAllOfValidator(items)),
nullTo: (defaultValue) => new validators_1.ValueMapper(value => ((0, validators_1.isNullOrUndefined)(value) ? defaultValue : value)),
array: (...items) => new validators_1.ArrayValidator((0, validators_1.maybeAllOfValidator)(items)),
toArray: (...items) => new validators_1.ArrayNormalizer((0, validators_1.maybeAllOfValidator)(items)),
size: (min, max) => new validators_1.SizeValidator(min, max),

@@ -56,0 +56,0 @@ properties: (keys, values) => new validators_1.ObjectValidator({ additionalProperties: { keys, values } }),

@@ -403,3 +403,3 @@ import { Path } from '@finnair/path';

}
export declare function isPromise(value: any): boolean;
export declare function isPromise(value: any): any;
export declare class IgnoreValidator extends Validator {

@@ -406,0 +406,0 @@ validatePath(value: any, path: Path, ctx: ValidationContext): Promise<ValidationResult>;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.JsonValidator = exports.IgnoreValidator = exports.isPromise = exports.ValueMapper = exports.OptionalValidator = exports.PatternNormalizer = exports.PatternValidator = exports.DateValidator = exports.AllOfValidator = exports.maybeAllOfValidator = exports.HasValueValidator = exports.AssertTrueValidator = exports.EnumValidator = exports.MaxValidator = exports.MinValidator = exports.NumberNormalizer = exports.NumberValidator = exports.isNumber = exports.NumberFormat = exports.BooleanNormalizer = exports.BooleanValidator = exports.NotBlankValidator = exports.SizeValidator = exports.NotEmptyValidator = exports.IsNullOrUndefinedValidator = exports.NotNullOrUndefinedValidator = exports.StringNormalizer = exports.StringValidator = exports.isSimplePrimitive = exports.isString = exports.AnyValidator = exports.JsonMap = exports.MapNormalizer = exports.MapValidator = exports.WhenGroup = exports.WhenGroupValidator = exports.Conditional = exports.IfValidator = exports.AnyOfValidator = exports.OneOfValidator = exports.CompositionValidator = exports.CheckValidator = exports.NextValidator = exports.ArrayNormalizer = exports.ArrayValidator = exports.MapEntryValidator = exports.ObjectNormalizer = exports.ObjectValidator = exports.mergeProperties = exports.ValidatorFnWrapper = exports.defaultViolations = exports.ValidatorType = exports.isNullOrUndefined = exports.Groups = exports.Group = exports.SizeViolation = exports.MaxViolation = exports.MinViolation = exports.OneOfMismatch = exports.PatternViolation = exports.HasValueViolation = exports.ErrorViolation = exports.EnumMismatch = exports.TypeMismatch = exports.Violation = exports.ValidationError = exports.ValidationResult = exports.Validator = exports.ValidationContext = void 0;
exports.BooleanNormalizer = exports.BooleanValidator = exports.NotBlankValidator = exports.SizeValidator = exports.NotEmptyValidator = exports.IsNullOrUndefinedValidator = exports.NotNullOrUndefinedValidator = exports.StringNormalizer = exports.StringValidator = exports.isSimplePrimitive = exports.isString = exports.AnyValidator = exports.JsonMap = exports.MapNormalizer = exports.MapValidator = exports.WhenGroup = exports.WhenGroupValidator = exports.Conditional = exports.IfValidator = exports.AnyOfValidator = exports.OneOfValidator = exports.CompositionValidator = exports.CheckValidator = exports.NextValidator = exports.ArrayNormalizer = exports.ArrayValidator = exports.MapEntryValidator = exports.ObjectNormalizer = exports.ObjectValidator = exports.mergeProperties = exports.ValidatorFnWrapper = exports.defaultViolations = exports.ValidatorType = exports.isNullOrUndefined = exports.Groups = exports.Group = exports.SizeViolation = exports.MaxViolation = exports.MinViolation = exports.OneOfMismatch = exports.PatternViolation = exports.HasValueViolation = exports.ErrorViolation = exports.EnumMismatch = exports.TypeMismatch = exports.Violation = exports.ValidationError = exports.ValidationResult = exports.Validator = exports.ValidationContext = void 0;
exports.JsonValidator = exports.IgnoreValidator = exports.isPromise = exports.ValueMapper = exports.OptionalValidator = exports.PatternNormalizer = exports.PatternValidator = exports.DateValidator = exports.AllOfValidator = exports.maybeAllOfValidator = exports.HasValueValidator = exports.AssertTrueValidator = exports.EnumValidator = exports.MaxValidator = exports.MinValidator = exports.NumberNormalizer = exports.NumberValidator = exports.isNumber = exports.NumberFormat = void 0;
const deep_equal_1 = __importDefault(require("deep-equal"));

@@ -1209,3 +1210,3 @@ const path_1 = require("@finnair/path");

return __awaiter(this, void 0, void 0, function* () {
if (deep_equal_1.default(value, this.expectedValue)) {
if ((0, deep_equal_1.default)(value, this.expectedValue)) {
return ctx.success(value);

@@ -1256,3 +1257,3 @@ }

if (resultValue !== value) {
if (convertedValue !== undefined && !deep_equal_1.default(resultValue, convertedValue)) {
if (convertedValue !== undefined && !(0, deep_equal_1.default)(resultValue, convertedValue)) {
throw new Error('Conflicting conversions');

@@ -1259,0 +1260,0 @@ }

{
"name": "@finnair/v-validation",
"version": "0.9.1",
"version": "1.0.0",
"private": false,

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

"dependencies": {
"@finnair/path": "^0.9.0",
"@finnair/path": "^1.0.0",
"@types/deep-equal": "1.0.1",

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

},
"gitHead": "3a3bea340e52e3c81c1caf6017d33e60c940c391"
"gitHead": "bd40a739be8c006e46f0b9f59426f435a971389b"
}
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