Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/TextInput/baseTextInputPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const propTypes = {
* @param {Object} props - props passed to the input
* @returns {Object} - returns an Error object if isFormInput is supplied but inputID is falsey or not a string
*/
inputID: props => FormUtils.getInputIDPropTypes(props),
inputID: props => FormUtils.validateInputIDProps(props),

/** Saves a draft of the input value when used in a form */
shouldSaveDraft: PropTypes.bool,
Expand Down
8 changes: 4 additions & 4 deletions src/libs/FormUtils.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/**
* Gets the prop type for inputID
* Custom prop validator that enforces inputID as a required string if isFormInput is true
*
* @param {Object} props - props passed to the input component
* @returns {Object} returns an Error object if isFormInput is supplied but inputID is falsey or not a string
*/
function getInputIDPropTypes(props) {
function validateInputIDProps(props) {
if (!props.isFormInput) {
return;
}
if (!props.inputID) {
return new Error('InputID is required if isFormInput prop is supplied.');
return new Error('inputID is required if isFormInput is true');
}
if (typeof props.inputID !== 'string') {
return new Error(`Invalid prop type ${typeof props.inputID} supplied to inputID. Expecting string.`);
Expand All @@ -18,5 +18,5 @@ function getInputIDPropTypes(props) {

export {
// eslint-disable-next-line import/prefer-default-export
getInputIDPropTypes,
validateInputIDProps,
};