{"record":{"id":"3044cf4216cb3111","repo":"marmelab/react-admin","slug":"referenceinput-does-not-accept-a-validate-prop","errorCode":null,"errorMessage":"<ReferenceInput> does not accept a validate prop. Set the validate prop on the child instead.","messagePattern":"<ReferenceInput> does not accept a validate prop\\. Set the validate prop on the child instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-ui-materialui/src/input/ReferenceInput.tsx","lineNumber":74,"sourceCode":" * @example\n * <ReferenceInput\n *      source=\"post_id\"\n *      reference=\"posts\"\n *      filter={{ is_published: true }}\n * />\n *\n * The enclosed component may filter results. ReferenceInput create a ChoicesContext which provides\n * a `setFilters` function. You can call this function to filter the results.\n */\nexport const ReferenceInput = (props: ReferenceInputProps) => {\n    const {\n        children = defaultChildren,\n        offline = defaultOffline,\n        ...rest\n    } = props;\n\n    if (props.validate && process.env.NODE_ENV !== 'production') {\n        throw new Error(\n            '<ReferenceInput> does not accept a validate prop. Set the validate prop on the child instead.'\n        );\n    }\n\n    return (\n        <ReferenceInputBase {...rest} offline={offline}>\n            {children}\n        </ReferenceInputBase>\n    );\n};\n\nconst defaultChildren = <AutocompleteInput />;\nconst defaultOffline = <Offline variant=\"inline\" />;\nexport interface ReferenceInputProps extends ReferenceInputBaseProps {\n    /**\n     * Call validate on the child component instead\n     */\n    validate?: never;","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-ui-materialui/src/input/ReferenceInput.tsx#L56-L92","documentation":"<ReferenceInput> delegates validation to the actual input element it wraps (the child), not to itself. Passing a `validate` prop on ReferenceInput would be silently ineffective, so in development the library throws to force you to move validate onto the child input. It only throws when process.env.NODE_ENV !== 'production'.","triggerScenarios":"Rendering <ReferenceInput source=\"user_id\" reference=\"users\" validate={required()} /> — the validate prop is present on ReferenceInput itself instead of on the child input like <AutocompleteInput validate={required()} />.","commonSituations":"Copying a form snippet where validate sat on a TextInput and pasting it onto ReferenceInput; migrating older code where validate on containers may have been tolerated; bulk-adding required() validation across form fields including reference fields.","solutions":["Move the validate prop from <ReferenceInput> to its child input component.","Combine validators with an array on the child if multiple rules are needed: validate={[required(), minValue(1)]}."],"exampleFix":"// before\n<ReferenceInput source=\"user_id\" reference=\"users\" validate={required()}>\n  <AutocompleteInput optionText=\"name\" />\n</ReferenceInput>\n\n// after\n<ReferenceInput source=\"user_id\" reference=\"users\">\n  <AutocompleteInput optionText=\"name\" validate={required()} />\n</ReferenceInput>","handlingStrategy":"validation","validationCode":"if ('validate' in referenceInputProps) {\n  throw new Error('Put validate on the child input of ReferenceInput, not on ReferenceInput');\n}","typeGuard":"type NoValidateProps<T> = Omit<T, 'validate'>;\nconst isValidateFree = <T extends { validate?: unknown }>(props: T): props is Omit<T, 'validate'> =>\n  !('validate' in props);","tryCatchPattern":null,"preventionTips":["Always put validate on the leaf input (AutocompleteInput, SelectArrayInput), not the container","When wrapping ReferenceInput in a helper component, type props as Omit<ReferenceInputProps, 'validate'>","Code-review forms for validate on any *Input container components"],"tags":["react-admin","reference-input","validation","props"],"backgroundTag":"invalid-prop-target","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}