+17
| import { Flaw } from "./Flaw" | ||
| import { Type } from "./Type" | ||
| class BooleanClass extends Type<boolean> { | ||
| readonly name = "boolean" | ||
| constructor() { | ||
| super() | ||
| } | ||
| is(value: any | boolean): value is boolean { | ||
| return typeof value == "boolean" | ||
| } | ||
| flaw(value: any): true | Flaw { | ||
| return this.is(value) || { type: this.name } | ||
| } | ||
| } | ||
| export type Boolean = BooleanClass | ||
| export const boolean = new BooleanClass() |
+4
-0
@@ -0,1 +1,2 @@ | ||
| import { Flaw } from "./Flaw" | ||
| import { Type } from "./Type" | ||
@@ -12,2 +13,5 @@ | ||
| } | ||
| flaw(value: any): true | Flaw { | ||
| return this.is(value) || { type: this.name } | ||
| } | ||
| } | ||
@@ -14,0 +18,0 @@ export type Array<T> = ArrayClass<T> |
+2
-0
@@ -0,1 +1,2 @@ | ||
| import { Flaw } from "./Flaw"; | ||
| import { Type } from "./Type"; | ||
@@ -7,2 +8,3 @@ declare class ArrayClass<T> extends Type<T[]> { | ||
| is(value: any | T[]): value is T[]; | ||
| flaw(value: any): true | Flaw; | ||
| } | ||
@@ -9,0 +11,0 @@ export declare type Array<T> = ArrayClass<T>; |
+3
-0
@@ -11,2 +11,5 @@ import { Type } from "./Type"; | ||
| } | ||
| flaw(value) { | ||
| return this.is(value) || { type: this.name }; | ||
| } | ||
| } | ||
@@ -13,0 +16,0 @@ export function array(item) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"Array.js","sourceRoot":"../","sources":["Array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,UAAc,SAAQ,IAAS;IAEpC,YAAqB,IAAa;QACjC,KAAK,EAAE,CAAA;QADa,SAAI,GAAJ,IAAI,CAAS;QAEjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClC,CAAC;IACD,EAAE,CAAC,KAAgB;QAClB,OAAO,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAClF,CAAC;CACD;AAED,MAAM,UAAU,KAAK,CAAI,IAAa;IACrC,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC"} | ||
| {"version":3,"file":"Array.js","sourceRoot":"../","sources":["Array.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,UAAc,SAAQ,IAAS;IAEpC,YAAqB,IAAa;QACjC,KAAK,EAAE,CAAA;QADa,SAAI,GAAJ,IAAI,CAAS;QAEjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClC,CAAC;IACD,EAAE,CAAC,KAAgB;QAClB,OAAO,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAClF,CAAC;IACD,IAAI,CAAC,KAAU;QACd,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IAC7C,CAAC;CACD;AAED,MAAM,UAAU,KAAK,CAAI,IAAa;IACrC,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC"} |
+9
-2
@@ -0,9 +1,16 @@ | ||
| import { Flaw } from "./Flaw"; | ||
| import { Type } from "./Type"; | ||
| declare class NumberClass extends Type<number> { | ||
| private readonly criteria?; | ||
| readonly condition?: string | undefined; | ||
| readonly name = "number"; | ||
| constructor(); | ||
| constructor(criteria?: ((value: number) => boolean) | undefined, condition?: string | undefined); | ||
| is(value: any | number): value is number; | ||
| flaw(value: any): true | Flaw; | ||
| } | ||
| export declare type Number = NumberClass; | ||
| export declare const number: NumberClass; | ||
| export declare namespace Number { | ||
| type Criteria = "positive" | "negative" | "integer"; | ||
| } | ||
| export declare function number(criteria?: number | Number.Criteria | Number.Criteria[] | number[] | ((value: number) => boolean)): NumberClass; | ||
| export {}; |
+25
-3
| import { Type } from "./Type"; | ||
| class NumberClass extends Type { | ||
| constructor() { | ||
| constructor(criteria, condition) { | ||
| super(); | ||
| this.criteria = criteria; | ||
| this.condition = condition; | ||
| this.name = "number"; | ||
| } | ||
| is(value) { | ||
| return typeof value == "number"; | ||
| return typeof value == "number" && (!this.criteria || this.criteria(value)); | ||
| } | ||
| flaw(value) { | ||
| return this.is(value) || { type: this.name }; | ||
| } | ||
| } | ||
| export const number = new NumberClass(); | ||
| export function number(criteria) { | ||
| function fromCriteria(criteria) { | ||
| return typeof criteria == "number" | ||
| ? value => value == criteria | ||
| : criteria == "positive" | ||
| ? value => value > 0 | ||
| : criteria == "negative" | ||
| ? value => value < 0 | ||
| : criteria == "integer" | ||
| ? Number.isInteger | ||
| : ((c) => Array.isArray(c) && c.every(c => typeof c == "number"))(criteria) | ||
| ? value => criteria.map(fromCriteria).some(c => c(value)) | ||
| : ((c) => Array.isArray(c) && c.every(c => typeof c == "string"))(criteria) | ||
| ? value => criteria.map(fromCriteria).every(c => c(value)) | ||
| : criteria; | ||
| } | ||
| return new NumberClass(criteria == undefined ? undefined : fromCriteria(criteria)); | ||
| } | ||
| //# sourceMappingURL=Number.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"Number.js","sourceRoot":"../","sources":["Number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,WAAY,SAAQ,IAAY;IAErC;QACC,KAAK,EAAE,CAAA;QAFC,SAAI,GAAG,QAAQ,CAAA;IAGxB,CAAC;IACD,EAAE,CAAC,KAAmB;QACrB,OAAO,OAAO,KAAK,IAAI,QAAQ,CAAA;IAChC,CAAC;CACD;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAA"} | ||
| {"version":3,"file":"Number.js","sourceRoot":"../","sources":["Number.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,WAAY,SAAQ,IAAY;IAErC,YAA6B,QAAqC,EAAW,SAAkB;QAC9F,KAAK,EAAE,CAAA;QADqB,aAAQ,GAAR,QAAQ,CAA6B;QAAW,cAAS,GAAT,SAAS,CAAS;QADtF,SAAI,GAAG,QAAQ,CAAA;IAGxB,CAAC;IACD,EAAE,CAAC,KAAmB;QACrB,OAAO,OAAO,KAAK,IAAI,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5E,CAAC;IACD,IAAI,CAAC,KAAU;QACd,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IAC7C,CAAC;CACD;AAKD,MAAM,UAAU,MAAM,CACrB,QAAiG;IAEjG,SAAS,YAAY,CACpB,QAAgG;QAEhG,OAAO,OAAO,QAAQ,IAAI,QAAQ;YACjC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,QAAQ;YAC5B,CAAC,CAAC,QAAQ,IAAI,UAAU;gBACxB,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,GAAG,CAAC;gBACpB,CAAC,CAAC,QAAQ,IAAI,UAAU;oBACxB,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,GAAG,CAAC;oBACpB,CAAC,CAAC,QAAQ,IAAI,SAAS;wBACvB,CAAC,CAAC,MAAM,CAAC,SAAS;wBAClB,CAAC,CAAC,CAAC,CAAC,CAAM,EAAiB,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;4BAC/F,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;4BACzD,CAAC,CAAC,CAAC,CAAC,CAAM,EAA0B,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;gCACxG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gCAC1D,CAAC,CAAC,QAAQ,CAAA;IACZ,CAAC;IACD,OAAO,IAAI,WAAW,CAAC,QAAQ,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAA;AACnF,CAAC"} |
+2
-0
@@ -0,1 +1,2 @@ | ||
| import { Flaw } from "./Flaw"; | ||
| import { Type } from "./Type"; | ||
@@ -7,2 +8,3 @@ declare class StringClass extends Type<string> { | ||
| is(value: any | string): value is string; | ||
| flaw(value: any): true | Flaw; | ||
| } | ||
@@ -9,0 +11,0 @@ export declare type String = StringClass; |
+3
-0
@@ -11,2 +11,5 @@ import { Type } from "./Type"; | ||
| } | ||
| flaw(value) { | ||
| return this.is(value) || { type: this.name }; | ||
| } | ||
| } | ||
@@ -13,0 +16,0 @@ export function string(...strings) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"String.js","sourceRoot":"../","sources":["String.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,WAAY,SAAQ,IAAY;IAErC,YAAqB,OAAkB;QACtC,KAAK,EAAE,CAAA;QADa,YAAO,GAAP,OAAO,CAAW;QAD9B,SAAI,GAAG,QAAQ,CAAA;IAGxB,CAAC;IACD,EAAE,CAAC,KAAmB;QACrB,OAAO,OAAO,KAAK,IAAI,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;IACnF,CAAC;CACD;AAID,MAAM,UAAU,MAAM,CAAC,GAAG,OAAiB;IAC1C,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;AAClE,CAAC"} | ||
| {"version":3,"file":"String.js","sourceRoot":"../","sources":["String.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,WAAY,SAAQ,IAAY;IAErC,YAAqB,OAAkB;QACtC,KAAK,EAAE,CAAA;QADa,YAAO,GAAP,OAAO,CAAW;QAD9B,SAAI,GAAG,QAAQ,CAAA;IAGxB,CAAC;IACD,EAAE,CAAC,KAAmB;QACrB,OAAO,OAAO,KAAK,IAAI,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;IACnF,CAAC;IACD,IAAI,CAAC,KAAU;QACd,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IAC7C,CAAC;CACD;AAID,MAAM,UAAU,MAAM,CAAC,GAAG,OAAiB;IAC1C,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;AAClE,CAAC"} |
+2
-2
| import { Flaw } from "./Flaw"; | ||
| export declare abstract class Type<T> { | ||
| abstract readonly name: string; | ||
| readonly condition?: ""; | ||
| readonly condition?: string; | ||
| abstract is(value: any | T): value is T; | ||
| flaw(value: any): true | Flaw; | ||
| abstract flaw(value: any): true | Flaw; | ||
| } |
+2
-2
| export class Type { | ||
| flaw(value) { | ||
| return this.is(value) || { type: this.name }; | ||
| constructor() { | ||
| this.condition = ""; | ||
| } | ||
| } | ||
| //# sourceMappingURL=Type.js.map |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"Type.js","sourceRoot":"../","sources":["Type.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,IAAI;IAIzB,IAAI,CAAC,KAAU;QACd,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IAC7C,CAAC;CACD"} | ||
| {"version":3,"file":"Type.js","sourceRoot":"../","sources":["Type.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,IAAI;IAA1B;QAEU,cAAS,GAAY,EAAE,CAAA;IAGjC,CAAC;CAAA"} |
+2
-0
@@ -0,1 +1,2 @@ | ||
| import { Flaw } from "./Flaw"; | ||
| import { Type } from "./Type"; | ||
@@ -7,2 +8,3 @@ declare class UnionClass<T> extends Type<T> { | ||
| is(value: any | T): value is T; | ||
| flaw(value: any): true | Flaw; | ||
| } | ||
@@ -9,0 +11,0 @@ export declare type Union<T> = UnionClass<T>; |
+6
-0
@@ -11,2 +11,8 @@ import { Type } from "./Type"; | ||
| } | ||
| flaw(value) { | ||
| return (this.is(value) || { | ||
| type: this.name, | ||
| flaws: this.types.map(type => type.flaw(value)).filter(flaw => flaw != true), | ||
| }); | ||
| } | ||
| } | ||
@@ -13,0 +19,0 @@ export function union(...types) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"Union.js","sourceRoot":"../","sources":["Union.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,UAAc,SAAQ,IAAO;IAElC,YAAqB,KAAgB;QACpC,KAAK,EAAE,CAAA;QADa,UAAK,GAAL,KAAK,CAAW;QAEpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC1D,CAAC;IACD,EAAE,CAAC,KAAc;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAC/C,CAAC;CACD;AAED,MAAM,UAAU,KAAK,CAAI,GAAG,KAAgB;IAC3C,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAA;AAC7B,CAAC"} | ||
| {"version":3,"file":"Union.js","sourceRoot":"../","sources":["Union.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,UAAc,SAAQ,IAAO;IAElC,YAAqB,KAAgB;QACpC,KAAK,EAAE,CAAA;QADa,UAAK,GAAL,KAAK,CAAW;QAEpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC1D,CAAC;IACD,EAAE,CAAC,KAAc;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAC/C,CAAC;IACD,IAAI,CAAC,KAAU;QACd,OAAO,CACN,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,IAAI,CAAW;SACtF,CACD,CAAA;IACF,CAAC;CACD;AAED,MAAM,UAAU,KAAK,CAAI,GAAG,KAAgB;IAC3C,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAA;AAC7B,CAAC"} |
+31
-3
@@ -0,1 +1,2 @@ | ||
| import { Flaw } from "./Flaw" | ||
| import { Type } from "./Type" | ||
@@ -5,10 +6,37 @@ | ||
| readonly name = "number" | ||
| constructor() { | ||
| constructor(private readonly criteria?: (value: number) => boolean, readonly condition?: string) { | ||
| super() | ||
| } | ||
| is(value: any | number): value is number { | ||
| return typeof value == "number" | ||
| return typeof value == "number" && (!this.criteria || this.criteria(value)) | ||
| } | ||
| flaw(value: any): true | Flaw { | ||
| return this.is(value) || { type: this.name } | ||
| } | ||
| } | ||
| export type Number = NumberClass | ||
| export const number = new NumberClass() | ||
| export namespace Number { | ||
| export type Criteria = "positive" | "negative" | "integer" | ||
| } | ||
| export function number( | ||
| criteria?: number | Number.Criteria | Number.Criteria[] | number[] | ((value: number) => boolean) | ||
| ) { | ||
| function fromCriteria( | ||
| criteria: number | Number.Criteria | Number.Criteria[] | number[] | ((value: number) => boolean) | ||
| ): (value: number) => boolean { | ||
| return typeof criteria == "number" | ||
| ? value => value == criteria | ||
| : criteria == "positive" | ||
| ? value => value > 0 | ||
| : criteria == "negative" | ||
| ? value => value < 0 | ||
| : criteria == "integer" | ||
| ? Number.isInteger | ||
| : ((c: any): c is number[] => Array.isArray(c) && c.every(c => typeof c == "number"))(criteria) | ||
| ? value => criteria.map(fromCriteria).some(c => c(value)) | ||
| : ((c: any): c is Number.Criteria[] => Array.isArray(c) && c.every(c => typeof c == "string"))(criteria) | ||
| ? value => criteria.map(fromCriteria).every(c => c(value)) | ||
| : criteria | ||
| } | ||
| return new NumberClass(criteria == undefined ? undefined : fromCriteria(criteria)) | ||
| } |
+1
-1
| { | ||
| "name": "isly", | ||
| "version": "0.0.3", | ||
| "version": "0.0.4", | ||
| "description": "Library for type checking.", | ||
@@ -5,0 +5,0 @@ "author": "Utily Contributors", |
+4
-0
@@ -0,1 +1,2 @@ | ||
| import { Flaw } from "./Flaw" | ||
| import { Type } from "./Type" | ||
@@ -11,2 +12,5 @@ | ||
| } | ||
| flaw(value: any): true | Flaw { | ||
| return this.is(value) || { type: this.name } | ||
| } | ||
| } | ||
@@ -13,0 +17,0 @@ |
+2
-4
@@ -5,7 +5,5 @@ import { Flaw } from "./Flaw" | ||
| abstract readonly name: string | ||
| readonly condition?: "" | ||
| readonly condition?: string = "" | ||
| abstract is(value: any | T): value is T | ||
| flaw(value: any): true | Flaw { | ||
| return this.is(value) || { type: this.name } | ||
| } | ||
| abstract flaw(value: any): true | Flaw | ||
| } |
+9
-0
@@ -0,1 +1,2 @@ | ||
| import { Flaw } from "./Flaw" | ||
| import { Type } from "./Type" | ||
@@ -12,2 +13,10 @@ | ||
| } | ||
| flaw(value: any): true | Flaw { | ||
| return ( | ||
| this.is(value) || { | ||
| type: this.name, | ||
| flaws: this.types.map(type => type.flaw(value)).filter(flaw => flaw != true) as Flaw[], | ||
| } | ||
| ) | ||
| } | ||
| } | ||
@@ -14,0 +23,0 @@ export type Union<T> = UnionClass<T> |
-91
| export interface Order { | ||
| id: authly.Identifier | ||
| number?: string | ||
| client?: string | ||
| created: isoly.DateTime | ||
| customer?: Contact | authly.Identifier | ||
| items: number | Item | Item[] | ||
| currency: isoly.Currency | ||
| payment: Payment | ||
| subscription?: authly.Identifier | ||
| event?: Event[] | ||
| status?: Status[] | OrderStatusList | ||
| theme?: string | ||
| meta?: any | ||
| callback?: string | ||
| language?: isoly.Language | ||
| category?: "purchase" | "withdrawal" | ||
| } | ||
| export namespace Order { | ||
| export function is(value: Order | any): value is Order { | ||
| return ( | ||
| typeof value == "object" && | ||
| authly.Identifier.is(value.id, 16) && | ||
| (typeof value.number == "string" || value.number == undefined) && | ||
| (typeof value.client == "string" || value.client == undefined) && | ||
| isoly.DateTime.is(value.created) && | ||
| (value.customer == undefined || Contact.is(value.customer) || authly.Identifier.is(value.customer, 16)) && | ||
| Item.canBe(value.items) && | ||
| isoly.Currency.is(value.currency) && | ||
| Payment.is(value.payment) && | ||
| (value.subscription == undefined || authly.Identifier.is(value.subscription, 4)) && | ||
| (value.event == undefined || (Array.isArray(value.event) && value.event.every(Event.is))) && | ||
| (value.status == undefined || | ||
| (Array.isArray(value.status) && value.status.every(Status.is)) || | ||
| OrderStatusList.is(value.status)) && | ||
| (value.theme == undefined || typeof value.theme == "string") && | ||
| (typeof value.callback == "string" || value.callback == undefined) && | ||
| (value.language == undefined || isoly.Language.is(value.language)) && | ||
| (value.category == undefined || value.category == "purchase" || value.category == "withdrawal") | ||
| ) | ||
| } | ||
| export function flaw(value: Order | any): gracely.Flaw { | ||
| return { | ||
| type: "model.Order", | ||
| flaws: | ||
| typeof value != "object" | ||
| ? undefined | ||
| : ([ | ||
| authly.Identifier.is(value.id, 16) || { | ||
| property: "id", | ||
| type: "authly.Identifier", | ||
| condition: "length == 16", | ||
| }, | ||
| typeof value.number == "string" || | ||
| value.number == undefined || { property: "number", type: "string | undefined" }, | ||
| typeof value.client == "string" || | ||
| value.client == undefined || { property: "client", type: "string | undefined" }, | ||
| isoly.DateTime.is(value.created) || { property: "created", type: "DateTime" }, | ||
| value.customer == undefined || | ||
| Contact.is(value.customer) || | ||
| authly.Identifier || { property: "customer", type: "Customer | undefined" }, | ||
| Item.canBe(value.items) || { property: "items", type: "number | Item | Item[]" }, | ||
| isoly.Currency.is(value.currency) || { property: "currency", type: "Currency" }, | ||
| Payment.is(value.payment) || { property: "payment", type: "Payment" }, | ||
| value.event == undefined || | ||
| (Array.isArray(value.event) && value.event.every(Event.is)) || { | ||
| property: "event", | ||
| type: "Event[] | undefined", | ||
| }, | ||
| value.status == undefined || | ||
| (Array.isArray(value.status) && value.status.every(Status.is)) || | ||
| StatusList.is(value.status) || { | ||
| property: "status", | ||
| type: "Status[] | { [status in Status]?: number | undefined } | undefined", | ||
| }, | ||
| value.theme == undefined || | ||
| typeof value.theme == "string" || { property: "theme", type: "string | undefined" }, | ||
| value.callback == undefined || | ||
| typeof value.callback == "string" || { property: "callback", type: "string | undefined" }, | ||
| value.language == undefined || | ||
| isoly.Language.is(value.language) || { property: "language", type: "isoly.Language | undefined" }, | ||
| value.category == undefined || | ||
| value.category == "purchase" || | ||
| value.category == "withdrawal" || { | ||
| property: "category", | ||
| type: `"purchase" | "withdrawal" | undefined`, | ||
| }, | ||
| ].filter(gracely.Flaw.is) as gracely.Flaw[]), | ||
| } | ||
| } | ||
| } |
34347
6.22%590
2.61%