-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow frozen objects/arrays to be coerced (#1151)
* Add frozen objects/arrays tests * Update record coercer * Update tuple coercer * Update `record()` struct to only coerce non-array objects
- Loading branch information
1 parent
5d18222
commit be4bc95
Showing
6 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { array, number } from '../../../src' | ||
|
||
export const Struct = array(number()) | ||
|
||
export const data = Object.freeze([1, 2, 3]) | ||
|
||
export const output = [1, 2, 3] | ||
|
||
export const create = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { object, string, number } from '../../../src' | ||
|
||
export const Struct = object({ | ||
name: string(), | ||
age: number(), | ||
}) | ||
|
||
export const data = Object.freeze({ | ||
name: 'john', | ||
age: 42, | ||
}) | ||
|
||
export const output = { | ||
name: 'john', | ||
age: 42, | ||
} | ||
|
||
export const create = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { record, string, number } from '../../../src' | ||
|
||
export const Struct = record(string(), number()) | ||
|
||
export const data = Object.freeze({ | ||
a: 1, | ||
b: 2, | ||
}) | ||
|
||
export const output = { | ||
a: 1, | ||
b: 2, | ||
} | ||
|
||
export const create = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { tuple, string, number } from '../../../src' | ||
|
||
export const Struct = tuple([string(), number()]) | ||
|
||
export const data = Object.freeze(['A', 1]) | ||
|
||
export const output = ['A', 1] | ||
|
||
export const create = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { type, string, number } from '../../../src' | ||
|
||
export const Struct = type({ | ||
name: string(), | ||
age: number(), | ||
}) | ||
|
||
export const data = Object.freeze({ | ||
name: 'john', | ||
age: 42, | ||
}) | ||
|
||
export const output = { | ||
name: 'john', | ||
age: 42, | ||
} | ||
|
||
export const create = true |