@sanity/validation
Advanced tools
Comparing version 0.133.0-next.ddda7af6 to 0.133.0-realtime-block-editor.72c3aa98
@@ -9,2 +9,6 @@ 'use strict'; | ||
var _require2 = require('./validators/blockValidator'); | ||
const blockValidator = _require2.blockValidator; | ||
// eslint-disable-next-line complexity | ||
@@ -48,2 +52,10 @@ | ||
if (type && type.name === 'block') { | ||
base = base.custom(blockValidator); | ||
} | ||
if (typeDef.annotations) { | ||
typeDef.annotations.forEach(annotation => inferFromSchemaType(annotation)); | ||
} | ||
if (typeDef.options && typeDef.options.list) { | ||
@@ -50,0 +62,0 @@ base = base.valid(typeDef.options.list.map(extractValueFromListOption)); |
@@ -70,2 +70,6 @@ 'use strict'; | ||
function processResult(result) { | ||
if (Array.isArray(result)) { | ||
return flatten(result.map(processResult)); | ||
} | ||
const hasError = result instanceof ValidationError; | ||
@@ -72,0 +76,0 @@ if (!hasError) { |
@@ -49,2 +49,4 @@ 'use strict'; | ||
module.exports.validateItem = validateItem; | ||
function validateObject(obj, type, path, options) { | ||
@@ -118,3 +120,2 @@ if (!type) { | ||
} | ||
// Validate items within array | ||
@@ -121,0 +122,0 @@ const itemChecks = items.map((item, i) => { |
@@ -87,2 +87,9 @@ 'use strict'; | ||
if (Array.isArray(result)) { | ||
if (result.length === 0) { | ||
return true; | ||
} | ||
return result; | ||
} | ||
if (result === true) { | ||
@@ -89,0 +96,0 @@ return true; |
{ | ||
"name": "@sanity/validation", | ||
"version": "0.133.0-next.ddda7af6", | ||
"version": "0.133.0-realtime-block-editor.72c3aa98", | ||
"description": "Validation and warning infrastructure for Sanity projects", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
const Rule = require('./Rule') | ||
const {slugValidator} = require('./validators/slugValidator') | ||
const {blockValidator} = require('./validators/blockValidator') | ||
@@ -43,2 +44,10 @@ // eslint-disable-next-line complexity | ||
if (type && type.name === 'block') { | ||
base = base.custom(blockValidator) | ||
} | ||
if (typeDef.annotations) { | ||
typeDef.annotations.forEach(annotation => inferFromSchemaType(annotation)) | ||
} | ||
if (typeDef.options && typeDef.options.list) { | ||
@@ -45,0 +54,0 @@ base = base.valid(typeDef.options.list.map(extractValueFromListOption)) |
@@ -66,2 +66,6 @@ const {get, flatten} = require('lodash') | ||
function processResult(result) { | ||
if (Array.isArray(result)) { | ||
return flatten(result.map(processResult)) | ||
} | ||
const hasError = result instanceof ValidationError | ||
@@ -68,0 +72,0 @@ if (!hasError) { |
@@ -33,2 +33,4 @@ const Type = require('type-of-is') | ||
module.exports.validateItem = validateItem | ||
function validateObject(obj, type, path, options) { | ||
@@ -90,3 +92,2 @@ if (!type) { | ||
} | ||
// Validate items within array | ||
@@ -93,0 +94,0 @@ const itemChecks = items.map((item, i) => { |
@@ -90,2 +90,9 @@ const Type = require('type-of-is') | ||
if (Array.isArray(result)) { | ||
if (result.length === 0) { | ||
return true | ||
} | ||
return result | ||
} | ||
if (result === true) { | ||
@@ -92,0 +99,0 @@ return true |
81221
45
2207