Skip to content

Commit 13514d1

Browse files
committed
fix(): casting
1 parent 98f4120 commit 13514d1

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@awell-health/awell-score",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "Library of Medical Score functions",
55
"packageManager": "yarn@4.6.0",
66
"main": "dist/index.js",

src/classes/Score.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ export class Score<
151151
* @returns The cast value.
152152
*/
153153
const castInputToExactType = (input_value: unknown, key: string) => {
154-
const inputTypeSchema = this.inputSchema[key].type
154+
const inputTypeSchema = this.inputSchema[key]?.type
155+
156+
if (!inputTypeSchema) return input_value
155157

156158
/**
157159
* Retrieves the base Zod type, unwrapping optional types if necessary.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { test_calculation } from './test_caculation'
2+
import { Score } from '../../classes/Score'
3+
4+
const calculation = new Score(test_calculation)
5+
6+
describe('Test Calculation', () => {
7+
it('should calculate the result', () => {
8+
const result = calculation.calculate({
9+
payload: {
10+
simpleNumberInput: '100',
11+
height: '100',
12+
weight: '100',
13+
hello: 'world',
14+
},
15+
})
16+
expect(result.result).toBe(10)
17+
})
18+
})

0 commit comments

Comments
 (0)