-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
team_settings
form error validation (#3368)
Changes requested by @DafyddLlyr have been made
- Loading branch information
Showing
7 changed files
with
73 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,16 @@ import { FormProps } from "."; | |
export default function ContactForm({ formikConfig, onSuccess }: FormProps) { | ||
const formSchema = Yup.object().shape({ | ||
helpEmail: Yup.string() | ||
.email("Please enter valid email") | ||
.required("Help Email is required"), | ||
helpPhone: Yup.string().required("Help Phone is required"), | ||
helpOpeningHours: Yup.string().required(), | ||
.email( | ||
"Enter an email address in the correct format, like [email protected]", | ||
) | ||
.required("Enter a help email address"), | ||
helpPhone: Yup.string().required("Enter a help phone number"), | ||
helpOpeningHours: Yup.string().required("Enter your opening hours"), | ||
homepage: Yup.string() | ||
.url("Please enter a valid URL for the homepage") | ||
.url( | ||
"Enter a homepage URL in the correct format, like https://www.localauthority.gov.uk/", | ||
) | ||
.required("Enter a homepage"), | ||
}); | ||
|
||
|
@@ -59,13 +63,15 @@ export default function ContactForm({ formikConfig, onSuccess }: FormProps) { | |
onChangeFn("homepage", event); | ||
}} | ||
value={formik.values.homepage} | ||
errorMessage={formik.errors.homepage} | ||
id="homepage" | ||
/> | ||
</InputLabel> | ||
<InputLabel label="Contact email address" htmlFor="helpEmail"> | ||
<Input | ||
name="helpEmail" | ||
value={formik.values.helpEmail} | ||
errorMessage={formik.errors.helpEmail} | ||
onChange={(event) => { | ||
onChangeFn("helpEmail", event); | ||
}} | ||
|
@@ -76,6 +82,7 @@ export default function ContactForm({ formikConfig, onSuccess }: FormProps) { | |
<Input | ||
name="helpPhone" | ||
value={formik.values.helpPhone} | ||
errorMessage={formik.errors.helpPhone} | ||
onChange={(event) => { | ||
onChangeFn("helpPhone", event); | ||
}} | ||
|
@@ -87,6 +94,7 @@ export default function ContactForm({ formikConfig, onSuccess }: FormProps) { | |
multiline | ||
name="helpOpeningHours" | ||
value={formik.values.helpOpeningHours} | ||
errorMessage={formik.errors.helpOpeningHours} | ||
onChange={(event) => { | ||
onChangeFn("helpOpeningHours", event); | ||
}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters