Skip to content

Commit 2cafef3

Browse files
committed
Fix proptypes for pattern
1 parent 0dac8a8 commit 2cafef3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/react-form-renderer/src/form-renderer/condition.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,18 @@ const conditionProps = {
151151
is: PropTypes.oneOfType([PropTypes.array, PropTypes.string, PropTypes.object, PropTypes.number, PropTypes.bool]),
152152
isNotEmpty: PropTypes.bool,
153153
isEmpty: PropTypes.bool,
154-
pattern: PropTypes.oneOf([PropTypes.string, PropTypes.instanceOf(RegExp)]),
154+
pattern: (props, name, componentName) => {
155+
if (typeof props[name] === 'string') {
156+
return;
157+
}
158+
159+
if (props[name] instanceof RegExp) {
160+
return;
161+
}
162+
163+
return new Error(`Invalid prop pattern supplied to condition in \`${componentName}\`. Validation failed.
164+
pattern has to be RegExp or string. Received \`${typeof props[name]}\`.`);
165+
},
155166
notMatch: PropTypes.any,
156167
then: PropTypes.shape({
157168
visible: PropTypes.bool,

0 commit comments

Comments
 (0)