import * as StringCheck from "../../../../sync/check/string"; import * as check from "../../../../sync/check/number"; export type PotentiallyUnsafeNumberStringResult = StringCheck.StringErrorCode|check.PotentiallyUnsafeNumberErrorCode; export function checkPotentiallyUnsafeNumberString (mixed : any) : undefined|PotentiallyUnsafeNumberStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkPotentiallyUnsafeNumber(toCheck); if (error !== undefined) { return error; } return undefined; }); } export type FiniteNumberStringResult = StringCheck.StringErrorCode|check.PotentiallyUnsafeNumberErrorCode|check.FiniteNumberErrorCode; export function checkFiniteNumberString (mixed : any) : undefined|FiniteNumberStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkFiniteNumber(toCheck); if (error !== undefined) { return error; } return undefined; }); } export type IntegerStringResult = StringCheck.StringErrorCode|check.IntegerErrorCodeType; export function checkIntegerString (mixed : any) : undefined|IntegerStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkInteger(toCheck); if (error !== undefined) { return error; } return undefined; }); } export type GreaterThanStringResult = StringCheck.StringErrorCode|check.PotentiallyUnsafeNumberErrorCode|check.FiniteNumberErrorCode|check.GreaterThanErrorCode; export function checkGreaterThanString (mixed : any, x : number) : undefined|GreaterThanStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkGreaterThan(toCheck, x); if (error !== undefined) { return error; } return undefined; }); } export type GreaterThanOrEqualStringResult = StringCheck.StringErrorCode|check.PotentiallyUnsafeNumberErrorCode|check.FiniteNumberErrorCode|check.GreaterThanOrEqualErrorCode; export function checkGreaterThanOrEqualString (mixed : any, x : number) : undefined|GreaterThanOrEqualStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkGreaterThanOrEqual(toCheck, x); if (error !== undefined) { return error; } return undefined; }); } export type LessThanStringResult = StringCheck.StringErrorCode|check.PotentiallyUnsafeNumberErrorCode|check.FiniteNumberErrorCode|check.LessThanErrorCode; export function checkLessThanString (mixed : any, x : number) : undefined|LessThanStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkLessThan(toCheck, x); if (error !== undefined) { return error; } return undefined; }); } export type LessThanOrEqualStringResult = StringCheck.StringErrorCode|check.PotentiallyUnsafeNumberErrorCode|check.FiniteNumberErrorCode|check.LessThanOrEqualErrorCode; export function checkLessThanOrEqualString (mixed : any, x : number) : undefined|LessThanOrEqualStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkLessThanOrEqual(toCheck, x); if (error !== undefined) { return error; } return undefined; }); } export type RangeStringResult = StringCheck.StringErrorCode|check.RangeErrorCodeType; export function checkRangeString (mixed : any, args : { min? : number, max? : number }) : undefined|RangeStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkRange(toCheck, args); if (error !== undefined) { return error; } return undefined; }); } export type PositiveStringResult = StringCheck.StringErrorCode|check.PotentiallyUnsafeNumberErrorCode|check.FiniteNumberErrorCode|check.PositiveErrorCode; export function checkPositiveString (mixed : any) : undefined|PositiveStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkPositive(toCheck); if (error !== undefined) { return error; } return undefined; }); } export type NegativeStringResult = StringCheck.StringErrorCode|check.PotentiallyUnsafeNumberErrorCode|check.FiniteNumberErrorCode|check.NegativeErrorCode; export function checkNegativeString (mixed : any) : undefined|NegativeStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkNegative(toCheck); if (error !== undefined) { return error; } return undefined; }); } export type NonNegativeStringResult = StringCheck.StringErrorCode|check.NonNegativeErrorCodeType; export function checkNonNegativeString (mixed : any) : undefined|NonNegativeStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkNonNegative(toCheck); if (error !== undefined) { return error; } return undefined; }); } export type NaturalNumberStringResult = StringCheck.StringErrorCode|check.NaturalNumberErrorCodeType; export function checkNaturalNumberString (mixed : any) : undefined|NaturalNumberStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkNaturalNumber(toCheck); if (error !== undefined) { return error; } return undefined; }); } export type OddStringResult = StringCheck.StringErrorCode|check.IntegerErrorCodeType|check.OddErrorCode; export function checkOddString (mixed : any) : undefined|OddStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkOdd(toCheck); if (error !== undefined) { return error; } return undefined; }); } export type EvenStringResult = StringCheck.StringErrorCode|check.IntegerErrorCodeType|check.EvenErrorCode; export function checkEvenString (mixed : any) : undefined|EvenStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkEven(toCheck); if (error !== undefined) { return error; } return undefined; }); } export type NotOneOfStringResult = StringCheck.StringErrorCode|check.NotOneOfErrorCodeType; export function checkNotOneOfString (mixed : any, arr : T[]) : undefined|NotOneOfStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkNotOneOf(toCheck, arr); if (error !== undefined) { return error; } return undefined; }); } export type LatitudeStringResult = StringCheck.StringErrorCode|check.LatitudeCodeErrorType; export function checkLatitudeString (mixed : any) : undefined|LatitudeStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkLatitude(toCheck); if (error !== undefined) { return error; } return undefined; }); } export type LongitudeStringResult = StringCheck.StringErrorCode|check.LongitudeCodeErrorType; export function checkLongitudeString (mixed : any) : undefined|LongitudeStringResult { return StringCheck.checkStringPredicate(mixed, (str) => { const toCheck = parseFloat(str); const error = check.checkLongitude(toCheck); if (error !== undefined) { return error; } return undefined; }); }