slate-prop-types
Advanced tools
Comparing version 0.5.32 to 0.5.33
@@ -18,5 +18,15 @@ (function (global, factory) { | ||
var value = props[propName]; | ||
if (value == null && !isRequired) return null; | ||
if (value == null && isRequired) return new Error('The ' + location + ' `' + propName + '` is marked as required in `' + componentName + '`, but it was not supplied.'); | ||
if (validate(value)) return null; | ||
if (value == null && !isRequired) { | ||
return null; | ||
} | ||
if (value == null && isRequired) { | ||
return new Error('The ' + location + ' `' + propName + '` is marked as required in `' + componentName + '`, but it was not supplied.'); | ||
} | ||
if (validate(value)) { | ||
return null; | ||
} | ||
return new Error('Invalid ' + location + ' `' + propName + '` supplied to `' + componentName + '`, expected a Slate `' + name + '` but received: ' + value); | ||
@@ -96,2 +106,5 @@ } | ||
}), | ||
selection: create('Selection', function (v) { | ||
return slate.Selection.isSelection(v); | ||
}), | ||
value: create('Value', function (v) { | ||
@@ -98,0 +111,0 @@ return slate.Value.isValue(v); |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("slate")):"function"==typeof define&&define.amd?define(["exports","slate"],n):n(e.SlatePropTypes={},e.Slate)}(this,function(e,n){"use strict";function t(e,n){function t(t,i,r,u,o){var a=i[r];return null!=a||t?null==a&&t?new Error("The "+o+" `"+r+"` is marked as required in `"+u+"`, but it was not supplied."):n(a)?null:new Error("Invalid "+o+" `"+r+"` supplied to `"+u+"`, expected a Slate `"+e+"` but received: "+a):null}function i(){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return t.apply(void 0,[!1].concat(n))}return i.isRequired=function(){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return t.apply(void 0,[!0].concat(n))},i}var i={block:t("Block",function(e){return n.Block.isBlock(e)}),blocks:t("List<Block>",function(e){return n.Block.isBlockList(e)}),change:t("Change",function(e){return n.Change.isChange(e)}),data:t("Data",function(e){return n.Data.isData(e)}),document:t("Document",function(e){return n.Document.isDocument(e)}),inline:t("Inline",function(e){return n.Inline.isInline(e)}),inlines:t("Inline",function(e){return n.Inline.isInlineList(e)}),leaf:t("Leaf",function(e){return n.Leaf.isLeaf(e)}),leaves:t("List<Leaf>",function(e){return n.Leaf.isLeafList(e)}),mark:t("Mark",function(e){return n.Mark.isMark(e)}),marks:t("Set<Mark>",function(e){return n.Mark.isMarkSet(e)}),node:t("Node",function(e){return n.Node.isNode(e)}),nodes:t("List<Node>",function(e){return n.Node.isNodeList(e)}),range:t("Range",function(e){return n.Range.isRange(e)}),ranges:t("List<Range>",function(e){return n.Range.isRangeList(e)}),value:t("Value",function(e){return n.Value.isValue(e)}),text:t("Text",function(e){return n.Text.isText(e)}),texts:t("List<Text>",function(e){return n.Text.isTextList(e)})};e.default=i,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("slate")):"function"==typeof define&&define.amd?define(["exports","slate"],n):n(e.SlatePropTypes={},e.Slate)}(this,function(e,n){"use strict";function t(e,n){function t(t,i,r,u,o){var a=i[r];return null!=a||t?null==a&&t?new Error("The "+o+" `"+r+"` is marked as required in `"+u+"`, but it was not supplied."):n(a)?null:new Error("Invalid "+o+" `"+r+"` supplied to `"+u+"`, expected a Slate `"+e+"` but received: "+a):null}function i(){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return t.apply(void 0,[!1].concat(n))}return i.isRequired=function(){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return t.apply(void 0,[!0].concat(n))},i}var i={block:t("Block",function(e){return n.Block.isBlock(e)}),blocks:t("List<Block>",function(e){return n.Block.isBlockList(e)}),change:t("Change",function(e){return n.Change.isChange(e)}),data:t("Data",function(e){return n.Data.isData(e)}),document:t("Document",function(e){return n.Document.isDocument(e)}),inline:t("Inline",function(e){return n.Inline.isInline(e)}),inlines:t("Inline",function(e){return n.Inline.isInlineList(e)}),leaf:t("Leaf",function(e){return n.Leaf.isLeaf(e)}),leaves:t("List<Leaf>",function(e){return n.Leaf.isLeafList(e)}),mark:t("Mark",function(e){return n.Mark.isMark(e)}),marks:t("Set<Mark>",function(e){return n.Mark.isMarkSet(e)}),node:t("Node",function(e){return n.Node.isNode(e)}),nodes:t("List<Node>",function(e){return n.Node.isNodeList(e)}),range:t("Range",function(e){return n.Range.isRange(e)}),ranges:t("List<Range>",function(e){return n.Range.isRangeList(e)}),selection:t("Selection",function(e){return n.Selection.isSelection(e)}),value:t("Value",function(e){return n.Value.isValue(e)}),text:t("Text",function(e){return n.Text.isText(e)}),texts:t("List<Text>",function(e){return n.Text.isTextList(e)})};e.default=i,Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -1,2 +0,2 @@ | ||
import { Block, Change, Data, Document, Inline, Leaf, Mark, Node, Range, Value, Text } from 'slate'; | ||
import { Block, Change, Data, Document, Inline, Leaf, Mark, Node, Range, Selection, Value, Text } from 'slate'; | ||
@@ -14,5 +14,15 @@ /** | ||
var value = props[propName]; | ||
if (value == null && !isRequired) return null; | ||
if (value == null && isRequired) return new Error('The ' + location + ' `' + propName + '` is marked as required in `' + componentName + '`, but it was not supplied.'); | ||
if (validate(value)) return null; | ||
if (value == null && !isRequired) { | ||
return null; | ||
} | ||
if (value == null && isRequired) { | ||
return new Error('The ' + location + ' `' + propName + '` is marked as required in `' + componentName + '`, but it was not supplied.'); | ||
} | ||
if (validate(value)) { | ||
return null; | ||
} | ||
return new Error('Invalid ' + location + ' `' + propName + '` supplied to `' + componentName + '`, expected a Slate `' + name + '` but received: ' + value); | ||
@@ -92,2 +102,5 @@ } | ||
}), | ||
selection: create('Selection', function (v) { | ||
return Selection.isSelection(v); | ||
}), | ||
value: create('Value', function (v) { | ||
@@ -94,0 +107,0 @@ return Value.isValue(v); |
@@ -18,5 +18,15 @@ 'use strict'; | ||
var value = props[propName]; | ||
if (value == null && !isRequired) return null; | ||
if (value == null && isRequired) return new Error('The ' + location + ' `' + propName + '` is marked as required in `' + componentName + '`, but it was not supplied.'); | ||
if (validate(value)) return null; | ||
if (value == null && !isRequired) { | ||
return null; | ||
} | ||
if (value == null && isRequired) { | ||
return new Error('The ' + location + ' `' + propName + '` is marked as required in `' + componentName + '`, but it was not supplied.'); | ||
} | ||
if (validate(value)) { | ||
return null; | ||
} | ||
return new Error('Invalid ' + location + ' `' + propName + '` supplied to `' + componentName + '`, expected a Slate `' + name + '` but received: ' + value); | ||
@@ -96,2 +106,5 @@ } | ||
}), | ||
selection: create('Selection', function (v) { | ||
return slate.Selection.isSelection(v); | ||
}), | ||
value: create('Value', function (v) { | ||
@@ -98,0 +111,0 @@ return slate.Value.isValue(v); |
{ | ||
"name": "slate-prop-types", | ||
"description": "A set of React prop type checkers for Slate editors.", | ||
"version": "0.5.32", | ||
"version": "0.5.33", | ||
"license": "MIT", | ||
@@ -21,3 +21,3 @@ "repository": "git://github.com/ianstormtaylor/slate.git", | ||
"mocha": "^2.5.3", | ||
"slate": "^0.46.1" | ||
"slate": "^0.47.0" | ||
}, | ||
@@ -24,0 +24,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
23913
336