import * as gracely from "gracely" import * as isoly from "isoly" export type Acceptor = Record<"mastercard" | "visa", Partial> | string> export namespace Acceptor { export function is(value: any | Acceptor): value is Acceptor { return ( typeof value == "object" && value && (typeof value.mastercard == "string" || (typeof value.mastercard == "object" && value.mastercard && Object.entries(value.mastercard).every( entry => isoly.Currency.is(entry[0]) && typeof entry[1] == "string" ))) && (typeof value.visa == "string" || (typeof value.visa == "object" && value.visa && Object.entries(value.visa).every(entry => isoly.Currency.is(entry[0]) && typeof entry[1] == "string"))) ) } export function flaw(value: any | Acceptor): gracely.Flaw { return { type: "Acceptor", flaws: typeof value != "object" || !value ? undefined : ([ typeof value.mastercard == "string" || (typeof value.mastercard == "object" && value.mastercard && Object.entries(value.mastercard).every( entry => isoly.Currency.is(entry[0]) && typeof entry[1] == "string" )) || { property: "mastercard", type: "Partial>> | string" }, typeof value.visa == "string" || (typeof value.visa == "object" && value.visa && Object.entries(value.visa).every( entry => isoly.Currency.is(entry[0]) && typeof entry[1] == "string" )) || { property: "visa", type: "Partial>> | string" }, ].filter(gracely.Flaw.is) as gracely.Flaw[]), } } }