( challengeType?: Prisma.JsonValue )
| 95 | * @returns The challenge type as a number or null. |
| 96 | */ |
| 97 | export const normalizeChallengeType = ( |
| 98 | challengeType?: Prisma.JsonValue |
| 99 | ): number | null => { |
| 100 | if (typeof challengeType === 'number') { |
| 101 | return challengeType; |
| 102 | } else if (typeof challengeType === 'string') { |
| 103 | const parsed = parseInt(challengeType, 10); |
| 104 | if (isNaN(parsed)) { |
| 105 | throw Error( |
| 106 | 'Unexpected challengeType value: ' + JSON.stringify(challengeType) |
| 107 | ); |
| 108 | } |
| 109 | return parsed; |
| 110 | } else if (challengeType === null) { |
| 111 | return null; |
| 112 | } else { |
| 113 | throw Error( |
| 114 | 'Unexpected challengeType value: ' + JSON.stringify(challengeType) |
| 115 | ); |
| 116 | } |
| 117 | }; |
| 118 | |
| 119 | /** |
| 120 | * Ensure that the user's profile UI settings are valid. |
no outgoing calls
no test coverage detected