+
Skip to content

Enhancement Request - Add IsActiveURL Validation Rule #257

@sCuz12

Description

@sCuz12

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"` }

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载