import * as check from "../../../../generated/sync/check/maybe/array"; import {AssertError} from "../../../../sync/error/AssertError"; export function assertMaybeArray (name : string, mixed : any) : (null|undefined|(any[]))|never { const error = check.checkMaybeArray(mixed); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed); } } export function assertMaybeMinLength (name : string, mixed : any, min : number) : (null|undefined|(any[]))|never { const error = check.checkMaybeMinLength(mixed, min); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed, min); } } export function assertMaybeMinLengthHandler (min : number) : (name : string, mixed : any) => (null|undefined|(any[]))|never { return (name : string, mixed : any) : (null|undefined|(any[]))|never => { return assertMaybeMinLength(name, mixed, min); }; } export function assertMaybeMaxLength (name : string, mixed : any, max : number) : (null|undefined|(any[]))|never { const error = check.checkMaybeMaxLength(mixed, max); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed, max); } } export function assertMaybeMaxLengthHandler (max : number) : (name : string, mixed : any) => (null|undefined|(any[]))|never { return (name : string, mixed : any) : (null|undefined|(any[]))|never => { return assertMaybeMaxLength(name, mixed, max); }; } export function assertMaybeLength (name : string, mixed : any, args : { min? : number, max? : number }) : (null|undefined|(any[]))|never { const error = check.checkMaybeLength(mixed, args); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed, args); } } export function assertMaybeLengthHandler (args : { min? : number, max? : number }) : (name : string, mixed : any) => (null|undefined|(any[]))|never { return (name : string, mixed : any) : (null|undefined|(any[]))|never => { return assertMaybeLength(name, mixed, args); }; } export function assertMaybeNonEmpty (name : string, mixed : any) : (null|undefined|(any[]))|never { const error = check.checkMaybeNonEmpty(mixed); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed); } } export function assertMaybeContains (name : string, mixed : any, x : any) : (null|undefined|(any[]))|never { const error = check.checkMaybeContains(mixed, x); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed, x); } } export function assertMaybeContainsHandler (x : any) : (name : string, mixed : any) => (null|undefined|(any[]))|never { return (name : string, mixed : any) : (null|undefined|(any[]))|never => { return assertMaybeContains(name, mixed, x); }; } export function assertMaybeNoDuplicate (name : string, mixed : any) : (null|undefined|(any[]))|never { const error = check.checkMaybeNoDuplicate(mixed); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed); } }