Changeset View
Changeset View
Standalone View
Standalone View
lib/utils/validation-utils.js
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | return t.refinement(t.Number, (input: number) => { | ||||
for (const num of nums) { | for (const num of nums) { | ||||
if (input === num) { | if (input === num) { | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
return false; | return false; | ||||
}); | }); | ||||
} | } | ||||
const tNull: TIrreducible<null> = t.irreducible('null', x => x === null); | |||||
const tDate: TRegex = tRegex(/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/); | const tDate: TRegex = tRegex(/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/); | ||||
const tColor: TRegex = tRegex(validHexColorRegex); // we don't include # char | const tColor: TRegex = tRegex(validHexColorRegex); // we don't include # char | ||||
const tPlatform: TEnums = t.enums.of([ | const tPlatform: TEnums = t.enums.of([ | ||||
'ios', | 'ios', | ||||
'android', | 'android', | ||||
'web', | 'web', | ||||
'windows', | 'windows', | ||||
'macos', | 'macos', | ||||
Show All 36 Lines | |||||
export { | export { | ||||
tBool, | tBool, | ||||
tString, | tString, | ||||
tNumber, | tNumber, | ||||
tShape, | tShape, | ||||
tRegex, | tRegex, | ||||
tNumEnum, | tNumEnum, | ||||
tNull, | |||||
tDate, | tDate, | ||||
tColor, | tColor, | ||||
tPlatform, | tPlatform, | ||||
tDeviceType, | tDeviceType, | ||||
tPlatformDetails, | tPlatformDetails, | ||||
tPassword, | tPassword, | ||||
tCookie, | tCookie, | ||||
tEmail, | tEmail, | ||||
tOldValidUsername, | tOldValidUsername, | ||||
tID, | tID, | ||||
tMediaMessagePhoto, | tMediaMessagePhoto, | ||||
tMediaMessageVideo, | tMediaMessageVideo, | ||||
tMediaMessageMedia, | tMediaMessageMedia, | ||||
assertWithValidator, | assertWithValidator, | ||||
}; | }; |