Skip to content

Commit

Permalink
[field] Fix error in object/array matching on shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Oct 6, 2020
1 parent 2b73579 commit cfbfbe6
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions packages/@sanity/field/src/validation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ import {SchemaType} from '../diff'

export function getValueError(value: unknown, schemaType: SchemaType) {
const {jsonType} = schemaType
const valueType = typeof value
const valueType = Array.isArray(value) ? 'array' : typeof value

if (value === null || valueType === 'undefined') {
return undefined
}

if (Array.isArray(value) && jsonType !== 'array') {
return {error: `Value is array, expected ${jsonType}`, value}
}

if (valueType !== jsonType) {
return {error: `Value is ${valueType}, expected ${jsonType}`, value}
}
Expand Down

0 comments on commit cfbfbe6

Please sign in to comment.