Require id only when label is given

This commit is contained in:
Kimmo Puputti 2017-06-20 14:02:35 +03:00
parent 77c7508af3
commit ede46ae006

View file

@ -181,6 +181,11 @@ BirthdayInput.propTypes = {
const BirthdayInputFieldComponent = props => {
const { rootClassName, className, id, label, input, meta } = props;
if (label && !id) {
throw new Error('id required when a label is given');
}
const classes = classNames(rootClassName || css.fieldRoot, className);
const inputProps = { id, ...input };
return (
@ -195,13 +200,14 @@ const BirthdayInputFieldComponent = props => {
BirthdayInputFieldComponent.defaultProps = {
rootClassName: null,
className: null,
id: null,
label: null,
};
BirthdayInputFieldComponent.propTypes = {
rootClassName: string,
className: string,
id: string.isRequired,
id: string,
label: string,
input: object.isRequired,
meta: object.isRequired,