Skip to content

Commit

Permalink
fix(hooks): coerce tuple keys to numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
soup-in-boots committed Apr 28, 2024
1 parent eacc5c8 commit ff08267
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/hooks/src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export function getNextSchema(schema, key) {
const preferredType = getPreferredType(schema.type);
if (preferredType === 'array') {
if (Array.isArray(schema.items)) {
key = Number(key);
if (Number.isInteger(key) && key < schema.items.length) {
return schema.items[key];
} else {
Expand All @@ -191,6 +192,7 @@ export function getNext(schema, key, value) {
const preferredType = getPreferredType(schema.type);
if (preferredType === 'array') {
if (Array.isArray(schema.items)) {
key = Number(key);
if (Number.isInteger(key) && key < schema.items.length) {
const nextSchema = schema.items[key];
const nextValue = assertType(nextSchema, value[key]);
Expand Down

0 comments on commit ff08267

Please sign in to comment.