Skip to content

Commit

Permalink
feat: Update regex and examples to restrict domain
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Jul 8, 2024
1 parent c4f1e3d commit c1db3f2
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ import { SettingsForm } from "../shared/SettingsForm";
import { FormProps } from ".";

export default function BoundaryForm({ formikConfig, onSuccess }: FormProps) {
const suffixRegEx = /\d{1,10}$/;
const planningDataURLRegex =
/^https:\/\/www\.planning\.data\.gov\.uk\/entity\/\d{7}$/;

const formSchema = Yup.object().shape({
boundaryUrl: Yup.string()
.matches(
suffixRegEx,
"Enter a boundary URL in the correct format, https://www.planning.data.gov.uk/entity/123456",
)
.url(
"Enter a boundary URL in the correct format, https://www.planning.data.gov.uk/entity/123456",
planningDataURLRegex,
"Enter a boundary URL in the correct format, https://www.planning.data.gov.uk/entity/1234567",
)
.required("Enter a boundary URL"),
});
Expand Down Expand Up @@ -70,7 +68,7 @@ export default function BoundaryForm({ formikConfig, onSuccess }: FormProps) {
target="_blank"
rel="noopener noreferrer"
>
https://www.planning.data.gov.uk/entity/123456
https://www.planning.data.gov.uk/entity/1234567
</a>
</p>
</>
Expand Down

0 comments on commit c1db3f2

Please sign in to comment.