Skip to content

Commit

Permalink
Add custom prop type checkers for radio and checkbox inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanna Letska authored and Hanna Letska committed Nov 29, 2018
1 parent 29a060c commit 036cc80
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/elements/Input/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Input.propTypes = {
/** HTML DOM attribute */
type: PropTypes.string,
bare: PropTypes.bool,
name: PropTypes.string.isRequired,
/** Placeholder for input */
placeholder: PropTypes.string,
/** Object of options for type of `select` */
Expand All @@ -126,13 +127,6 @@ Input.propTypes = {
);
}
},
name: (props, propName) => {
if ((props.type === 'radio' || props.type === 'checkbox') && (props[propName] === undefined)) {
return new Error(
'Name attribute is required for radio and checkbox inputs'
);
}
},
id: (props, propName) => {
if ((props.type === 'radio' || props.type === 'checkbox') && (props[propName] === undefined)) {
return new Error(
Expand Down

0 comments on commit 036cc80

Please sign in to comment.