-
Notifications
You must be signed in to change notification settings - Fork 122
Description
Issue Summary:
I would like to request the addition of a new validation rule called "IsActiveURL" to the validation package. This rule will be used to validate whether a given URL is an active and accessible website.
Description:
Currently, the validation package provides various rules for common validation tasks. However, there is a need for a specific rule to check if a URL is not only valid in format but also leads to an active website. This is especially useful for scenarios where we want to ensure that URLs provided by users actually lead to live webpages.
Expected Behavior:
The IsActiveURL validation rule should make an HTTP request to the provided URL and confirm that the URL is reachable and returns a valid response (e.g., status code 200). If the URL is unreachable or returns an invalid response, the validation should fail
Use Case:
Imagine a scenario where we have a form field for users to input their website URLs. We want to ensure that the URLs they provide are not only correctly formatted but also lead to active websites. This can be crucial for applications that rely on accurate and functioning URLs.
Example
type User struct { Website string `validate:"isActiveURL"` }