From a440dbe3128e4f7f009d1832b9d2c7326be77f18 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Wed, 1 Nov 2017 10:54:25 +0800 Subject: [PATCH] chore: don't allow empty string as value, close: ant-design/ant-design#5292 --- src/PropTypes.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/PropTypes.js b/src/PropTypes.js index ab944e6b..dd9c3ce2 100644 --- a/src/PropTypes.js +++ b/src/PropTypes.js @@ -1,9 +1,16 @@ import PropTypes from 'prop-types'; import { SHOW_ALL, SHOW_PARENT, SHOW_CHILD } from './strategies'; +function nonEmptyStringType(props, propsName) { + const value = props[propsName]; + if (typeof value !== 'string' || !value) { + return new Error(); // Just a flag, so don't need message. + } +} + function valueType(props, propName, componentName) { const labelInValueShape = PropTypes.shape({ - value: PropTypes.string.isRequired, + value: nonEmptyStringType, label: PropTypes.string, }); if (props.labelInValue) {