aws-amplify / aws-amplify/amplify-ui
Authenticator: Pass React hooks state to sign up validation logic
- Dominant language
- TypeScript
- Stars
- 1.1k
- Forks
- 347
- Avg merge
- 18h 29m
- Merged PRs (30d)
- 9
Description
### On which framework/platform would you like to see this feature implemented?
React
### Which UI component is this feature-request for?
Authenticator
### Please describe your feature-request in detail.
In the custom sign up validation example, it would be great if a React state can be used in the validation logic. Some validation logic may depend on the app state and configuration.
```
export default function App() {
return (
{/* Re-use default `Authenticator.SignUp.FormFields` */}
{/* Append & require Terms & Conditions field to sign up */}
);
},
},
}}
services={{
async validateCustomSignUp(formData) {
if (!formData.acknowledgement) {
return {
acknowledgement: 'You must agree to the Terms & Conditions',
};
}
},
}}
>
{({ signOut, user }) => (
Hello {user.username}
Sign out
)}
);
}
```
### Please describe a solution you'd like.
For example, if we have `const [stateVariable, setStateVariable] = useState(false)` in the React component, and want to pass `stateVariable` onto the validation logic like so:
```
async validateCustomSignUp(formData) {
if (formData.acknowledgement === stateVariable) {
return {
acknowledgement: 'You must agree to the Terms & Conditions',
};
}
```
### We love contributors! Is this something you'd be interested in working on?
- [X] 👋 I may be able to implement this feature request.
- [ ] ⚠️ This feature might incur a breaking change.
Contributor guide
Research direction
Start with the React Authenticator custom sign-up example and the services.validateCustomSignUp entry point shown in the issue. Trace how the validation callback is created and invoked, then define and verify behavior for React state or configuration, including an example or test that demonstrates the state reaches validation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- api, authentication, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100