import * as check from "../../../../generated/sync/check/maybe/string"; import {AssertError} from "../../../../sync/error/AssertError"; export function assertMaybeString (name : string, mixed : any) : (null|undefined|(string))|never { const error = check.checkMaybeString(mixed); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed); } } export function assertMaybeMinLength (name : string, mixed : any, min : number) : (null|undefined|(string))|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|(string))|never { return (name : string, mixed : any) : (null|undefined|(string))|never => { return assertMaybeMinLength(name, mixed, min); }; } export function assertMaybeMaxLength (name : string, mixed : any, max : number) : (null|undefined|(string))|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|(string))|never { return (name : string, mixed : any) : (null|undefined|(string))|never => { return assertMaybeMaxLength(name, mixed, max); }; } export function assertMaybeLength (name : string, mixed : any, args : { min? : number, max? : number }) : (null|undefined|(string))|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|(string))|never { return (name : string, mixed : any) : (null|undefined|(string))|never => { return assertMaybeLength(name, mixed, args); }; } export function assertMaybeNonEmpty (name : string, mixed : any) : (null|undefined|(string))|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 : string) : (null|undefined|(string))|never { const error = check.checkMaybeContains(mixed, x); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed, x); } } export function assertMaybeContainsHandler (x : string) : (name : string, mixed : any) => (null|undefined|(string))|never { return (name : string, mixed : any) : (null|undefined|(string))|never => { return assertMaybeContains(name, mixed, x); }; } export function assertMaybeNoDuplicate (name : string, mixed : any) : (null|undefined|(string))|never { const error = check.checkMaybeNoDuplicate(mixed); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed); } } export function assertMaybeNotAllWhitespace (name : string, mixed : any) : (null|undefined|(string))|never { const error = check.checkMaybeNotAllWhitespace(mixed); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed); } } export function assertMaybeNonEmptyAndNotAllWhitespace (name : string, mixed : any) : (null|undefined|(string))|never { const error = check.checkMaybeNonEmptyAndNotAllWhitespace(mixed); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed); } } export function assertMaybeMatch (name : string, mixed : any, regex : RegExp) : (null|undefined|(string))|never { const error = check.checkMaybeMatch(mixed, regex); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed, regex); } } export function assertMaybeMatchHandler (regex : RegExp) : (name : string, mixed : any) => (null|undefined|(string))|never { return (name : string, mixed : any) : (null|undefined|(string))|never => { return assertMaybeMatch(name, mixed, regex); }; } export function assertMaybeEmail (name : string, mixed : any) : (null|undefined|(string))|never { const error = check.checkMaybeEmail(mixed); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed); } } export function assertMaybeNotOneOf (name : string, mixed : any, arr : T[]) : (null|undefined|(string))|never { const error = check.checkMaybeNotOneOf(mixed, arr); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed, arr); } } export function assertMaybeNotOneOfHandler (arr : T[]) : (name : string, mixed : any) => (null|undefined|(string))|never { return (name : string, mixed : any) : (null|undefined|(string))|never => { return assertMaybeNotOneOf(name, mixed, arr); }; } export function assertMaybeBase64 (name : string, mixed : any) : (null|undefined|(string))|never { const error = check.checkMaybeBase64(mixed); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed); } } export function assertMaybeJson (name : string, mixed : any) : (null|undefined|(string))|never { const error = check.checkMaybeJson(mixed); if (error === undefined) { return mixed; } else { throw new AssertError(name, error, mixed); } }