@thisisagile/easy
Advanced tools
Comparing version 1.2.0 to 1.3.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Record = void 0; | ||
const validation_1 = require("../validation"); | ||
class Record { | ||
@@ -8,5 +9,5 @@ constructor(state) { | ||
} | ||
get isValid() { return true; } | ||
get isValid() { return validation_1.validate(this).isValid; } | ||
} | ||
exports.Record = Record; | ||
//# sourceMappingURL=Record.js.map |
export * from "./domain"; | ||
export * from "./services"; | ||
export * from "./test"; | ||
export * from "./types"; | ||
export * from "./utils"; | ||
export * from "./validation"; |
@@ -15,2 +15,3 @@ "use strict"; | ||
__exportStar(require("./services"), exports); | ||
__exportStar(require("./test"), exports); | ||
__exportStar(require("./types"), exports); | ||
@@ -17,0 +18,0 @@ __exportStar(require("./utils"), exports); |
@@ -9,1 +9,2 @@ import { Constructor } from "./Constructor"; | ||
export declare const isIn: (o: unknown, values: unknown[]) => boolean; | ||
export declare const isError: (e: unknown) => e is Error; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isIn = exports.isInstance = exports.isArray = exports.isObject = exports.isString = exports.isEmpty = exports.isDefined = void 0; | ||
exports.isError = exports.isIn = exports.isInstance = exports.isArray = exports.isObject = exports.isString = exports.isEmpty = exports.isDefined = void 0; | ||
const class_validator_1 = require("class-validator"); | ||
const IsA_1 = require("./IsA"); | ||
exports.isDefined = (o) => o !== undefined && o !== null; | ||
@@ -12,2 +13,3 @@ exports.isEmpty = (o) => o === "" || o === null || o === undefined; | ||
exports.isIn = (o, values) => exports.isArray(values) && values.some(v => v === o); | ||
exports.isError = (e) => IsA_1.isAn(e, "name", "message"); | ||
//# sourceMappingURL=Is.js.map |
import "reflect-metadata"; | ||
declare class ClassMeta { | ||
readonly subject: any; | ||
private readonly meta; | ||
constructor(subject: any, meta?: any); | ||
private readonly data; | ||
constructor(subject: any, data?: any); | ||
get: <T>(key: string) => T; | ||
@@ -15,4 +15,4 @@ set: <T>(key: string, value: T) => T; | ||
readonly property: string; | ||
private readonly meta; | ||
constructor(subject: unknown, property: string, meta?: any); | ||
private readonly data; | ||
constructor(subject: unknown, property: string, data?: any); | ||
get: <T>(key: string) => T; | ||
@@ -19,0 +19,0 @@ set: <T>(key: string, value: T) => T; |
@@ -7,10 +7,10 @@ "use strict"; | ||
class ClassMeta { | ||
constructor(subject, meta) { | ||
constructor(subject, data) { | ||
var _a; | ||
if (meta === void 0) { meta = ((_a = subject.prototype) !== null && _a !== void 0 ? _a : subject).constructor; } | ||
if (data === void 0) { data = ((_a = subject.prototype) !== null && _a !== void 0 ? _a : subject).constructor; } | ||
this.subject = subject; | ||
this.meta = meta; | ||
this.get = (key) => Reflect.getMetadata(key, this.meta); | ||
this.data = data; | ||
this.get = (key) => Reflect.getMetadata(key, this.data); | ||
this.set = (key, value) => { | ||
Reflect.defineMetadata(key, value, this.meta); | ||
Reflect.defineMetadata(key, value, this.data); | ||
return value; | ||
@@ -25,9 +25,9 @@ }; | ||
class PropertyMeta { | ||
constructor(subject, property, meta = Reflect.getMetadata(property, subject)) { | ||
constructor(subject, property, data = Reflect.getMetadata(property, subject)) { | ||
this.subject = subject; | ||
this.property = property; | ||
this.meta = meta; | ||
this.get = (key) => types_1.isDefined(this.meta) && types_1.isDefined(this.meta[key]) ? this.meta[key] : undefined; | ||
this.data = data; | ||
this.get = (key) => types_1.isDefined(this.data) && types_1.isDefined(this.data[key]) ? this.data[key] : undefined; | ||
this.set = (key, value) => { | ||
Reflect.defineMetadata(this.property, { ...this.meta, [key]: value }, this.subject); | ||
Reflect.defineMetadata(this.property, { ...this.data, [key]: value }, this.subject); | ||
return value; | ||
@@ -34,0 +34,0 @@ }; |
export * from "./Contraints"; | ||
export * from "./Results"; | ||
export * from "./Validate"; | ||
export * from "./When"; |
@@ -16,2 +16,3 @@ "use strict"; | ||
__exportStar(require("./Validate"), exports); | ||
__exportStar(require("./When"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -22,5 +22,5 @@ "use strict"; | ||
exports.validateReject = (subject) => { | ||
const results = exports.validate(subject); | ||
return results.isValid ? Promise.resolve(subject) : Promise.reject(results); | ||
const rs = exports.validate(subject); | ||
return rs.isValid ? Promise.resolve(subject) : Promise.reject(rs); | ||
}; | ||
//# sourceMappingURL=Validate.js.map |
{ | ||
"name": "@thisisagile/easy", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Straightforward library for building domain-driven microservice architectures", | ||
@@ -5,0 +5,0 @@ "author": "Sander Hoogendoorn", |
import {Validatable} from "../types"; | ||
import { validate } from '../validation'; | ||
export abstract class Record implements Validatable { | ||
get isValid(): boolean { return true } | ||
get isValid(): boolean { return validate(this).isValid; } | ||
constructor(protected state: any) {} | ||
} |
export * from "./domain"; | ||
export * from "./services"; | ||
export * from "./test"; | ||
export * from "./types"; | ||
export * from "./utils"; | ||
export * from "./validation"; |
import { isInstance as asInstance, isObject as asObject } from "class-validator"; | ||
import { Constructor } from "./Constructor"; | ||
import { isAn } from './IsA'; | ||
@@ -17,1 +18,3 @@ export const isDefined = (o?: unknown): boolean => o !== undefined && o !== null; | ||
export const isIn = (o: unknown, values: unknown[]): boolean => isArray(values) && values.some(v => v === o); | ||
export const isError = (e: unknown): e is Error => isAn<Error>(e, "name", "message"); |
@@ -5,8 +5,8 @@ import "reflect-metadata"; | ||
class ClassMeta { | ||
constructor(readonly subject: any, private readonly meta: any = (subject.prototype ?? subject).constructor) {} | ||
constructor(readonly subject: any, private readonly data: any = (subject.prototype ?? subject).constructor) {} | ||
get = <T>(key: string): T => Reflect.getMetadata(key, this.meta) as T; | ||
get = <T>(key: string): T => Reflect.getMetadata(key, this.data) as T; | ||
set = <T>(key: string, value: T): T => { | ||
Reflect.defineMetadata(key, value, this.meta); | ||
Reflect.defineMetadata(key, value, this.data); | ||
return value; | ||
@@ -27,8 +27,8 @@ }; | ||
class PropertyMeta { | ||
constructor(readonly subject: unknown, readonly property: string, private readonly meta = Reflect.getMetadata(property, subject)) {} | ||
constructor(readonly subject: unknown, readonly property: string, private readonly data = Reflect.getMetadata(property, subject)) {} | ||
get = <T>(key: string): T => isDefined(this.meta) && isDefined(this.meta[key]) ? this.meta[key] as T : undefined; | ||
get = <T>(key: string): T => isDefined(this.data) && isDefined(this.data[key]) ? this.data[key] as T : undefined; | ||
set = <T>(key: string, value: T): T => { | ||
Reflect.defineMetadata(this.property, { ...this.meta, [key]: value }, this.subject); | ||
Reflect.defineMetadata(this.property, { ...this.data, [key]: value }, this.subject); | ||
return value; | ||
@@ -35,0 +35,0 @@ }; |
export * from "./Contraints"; | ||
export * from "./Results"; | ||
export * from "./Validate"; | ||
export * from "./When"; |
@@ -25,4 +25,4 @@ import { isDefined, result, Result } from "../types"; | ||
export const validateReject = <T>(subject: T): Promise<T> => { | ||
const results = validate(subject); | ||
return results.isValid ? Promise.resolve(subject) : Promise.reject(results); | ||
const rs = validate(subject); | ||
return rs.isValid ? Promise.resolve(subject) : Promise.reject(rs); | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57471
115
819