@thisisagile/easy
Advanced tools
Comparing version 1.4.2 to 1.4.3
import { Json, Validatable } from '../types'; | ||
export declare abstract class Record implements Validatable { | ||
protected readonly state: any; | ||
constructor(state: any); | ||
constructor(state?: any); | ||
get isValid(): boolean; | ||
toJSON(): Json; | ||
} |
@@ -7,3 +7,3 @@ "use strict"; | ||
class Record { | ||
constructor(state) { | ||
constructor(state = {}) { | ||
this.state = state; | ||
@@ -10,0 +10,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Constructor } from "./Constructor"; | ||
import { Constructor } from './Constructor'; | ||
export declare const isDefined: (o?: unknown) => boolean; | ||
@@ -9,4 +9,3 @@ export declare const isEmpty: (o?: unknown) => boolean; | ||
export declare const isArray: <T = any>(o?: unknown) => o is T[]; | ||
export declare const isInstance: <T>(o: unknown, ctor: Constructor<T>) => o is T; | ||
export declare const isInstance: <T>(ctor: Constructor<T>, o?: unknown) => o is T; | ||
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.isError = exports.isIn = exports.isInstance = exports.isArray = exports.isFunction = exports.isObject = exports.isString = exports.isNotEmpty = exports.isEmpty = exports.isDefined = void 0; | ||
const class_validator_1 = require("class-validator"); | ||
const IsA_1 = require("./IsA"); | ||
exports.isIn = exports.isInstance = exports.isArray = exports.isFunction = exports.isObject = exports.isString = exports.isNotEmpty = exports.isEmpty = exports.isDefined = void 0; | ||
exports.isDefined = (o) => o !== undefined && o !== null; | ||
exports.isEmpty = (o) => o === "" || o === null || o === undefined; | ||
exports.isNotEmpty = (o) => o !== "" && o !== null && o !== undefined; | ||
exports.isString = (o) => o instanceof String || typeof o === "string"; | ||
exports.isObject = (o) => class_validator_1.isObject(o); | ||
exports.isEmpty = (o) => o === '' || o === null || o === undefined; | ||
exports.isNotEmpty = (o) => o !== '' && o !== null && o !== undefined; | ||
exports.isString = (o) => o instanceof String || typeof o === 'string'; | ||
exports.isObject = (o) => o != null && (typeof o === 'object' || typeof o === 'function') && !exports.isArray(o); | ||
exports.isFunction = (o) => exports.isDefined(o) && o instanceof Function; | ||
exports.isArray = (o) => exports.isDefined(o) && o instanceof Array; | ||
exports.isInstance = (o, ctor) => class_validator_1.isInstance(o, ctor); | ||
exports.isInstance = (ctor, o) => exports.isFunction(ctor) && o instanceof ctor; | ||
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 |
export declare const isA: <T>(t?: unknown, ...properties: (keyof T)[]) => t is T; | ||
export declare const isAn: <T>(t?: unknown, ...properties: (keyof T)[]) => t is T; | ||
export declare const isError: (e: unknown) => e is Error; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isAn = exports.isA = void 0; | ||
exports.isError = exports.isAn = exports.isA = void 0; | ||
const Is_1 = require("./Is"); | ||
exports.isA = (t, ...properties) => Is_1.isDefined(t) && properties.every(p => Is_1.isDefined(t[p])); | ||
exports.isAn = exports.isA; | ||
exports.isError = (e) => exports.isAn(e, "name", "message"); | ||
//# sourceMappingURL=IsA.js.map |
{ | ||
"name": "@thisisagile/easy", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"description": "Straightforward library for building domain-driven microservice architectures", | ||
@@ -5,0 +5,0 @@ "author": "Sander Hoogendoorn", |
@@ -5,3 +5,3 @@ import { Json, jsonify, Validatable } from '../types'; | ||
export abstract class Record implements Validatable { | ||
constructor(protected readonly state: any) {} | ||
constructor(protected readonly state: any = {}) {} | ||
@@ -8,0 +8,0 @@ get isValid(): boolean { return validate(this).isValid; } |
@@ -1,14 +0,12 @@ | ||
import { isInstance as asInstance, isObject as asObject } from "class-validator"; | ||
import { Constructor } from "./Constructor"; | ||
import { isAn } from './IsA'; | ||
import { Constructor } from './Constructor'; | ||
export const isDefined = (o?: unknown): boolean => o !== undefined && o !== null; | ||
export const isEmpty = (o?: unknown): boolean => o === "" || o === null || o === undefined; | ||
export const isEmpty = (o?: unknown): boolean => o === '' || o === null || o === undefined; | ||
export const isNotEmpty = (o?: unknown): boolean => o !== "" && o !== null && o !== undefined; | ||
export const isNotEmpty = (o?: unknown): boolean => o !== '' && o !== null && o !== undefined; | ||
export const isString = (o?: unknown): o is string => o instanceof String || typeof o === "string"; | ||
export const isString = (o?: unknown): o is string => o instanceof String || typeof o === 'string'; | ||
export const isObject = (o?: unknown): o is Object => asObject(o); | ||
export const isObject = (o?: unknown): o is Object => o != null && (typeof o === 'object' || typeof o === 'function') && !isArray(o); | ||
@@ -19,6 +17,4 @@ export const isFunction = (o?: unknown): o is Function => isDefined(o) && o instanceof Function; | ||
export const isInstance = <T>(o: unknown, ctor: Constructor<T>): o is T => asInstance(o, ctor); | ||
export const isInstance = <T>(ctor: Constructor<T>, o?: unknown): o is T => isFunction(ctor) && o instanceof ctor; | ||
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,1 +5,3 @@ import { isDefined } from "./Is"; | ||
export const isAn = isA; | ||
export const isError = (e: unknown): e is Error => isAn<Error>(e, "name", "message"); |
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
69714
977