Merge pull request #254 from zappityzap/pr-profile-validation

Add feedback for profile edits validation
This commit is contained in:
hzrd149 2024-11-03 14:45:48 +00:00 committed by GitHub
commit 1de297ea2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -74,8 +74,14 @@ const MetadataForm = ({ defaultValues, onSubmit }: MetadataFormProps) => {
autoComplete="off"
isDisabled={isSubmitting}
{...register("displayName", {
minLength: 2,
maxLength: 64,
minLength: {
value: 2,
message: "Must be at least 2 characters long",
},
maxLength: {
value: 64,
message: "Cannot exceed 64 characters",
}
})}
/>
<FormErrorMessage>{errors.displayName?.message}</FormErrorMessage>
@ -86,10 +92,19 @@ const MetadataForm = ({ defaultValues, onSubmit }: MetadataFormProps) => {
autoComplete="off"
isDisabled={isSubmitting}
{...register("username", {
minLength: 2,
maxLength: 64,
required: true,
pattern: /^[a-zA-Z0-9_-]{4,64}$/,
minLength: {
value: 2,
message: "Must be at least 2 characters long",
},
maxLength: {
value: 64,
message: "Cannot exceed 64 characters",
},
required: "Username is required",
pattern: {
value: /^[a-zA-Z0-9_-]{2,64}$/,
message: "Only letters, numbers, underscores, and hyphens, and must be 2-64 characters",
},
})}
/>
<FormErrorMessage>{errors.username?.message}</FormErrorMessage>