Total Lines | 18 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package is |
||
2 | |||
3 | import "github.com/muonsoft/validation/validate" |
||
4 | |||
5 | // URL is used to check that value is a valid absolute URL string, which means that a protocol (or scheme) is required. |
||
6 | // By default (if no protocols are passed), the function checks only for the http:// and https:// protocols. |
||
7 | // Use the protocols argument to configure the list of expected protocols. |
||
8 | func URL(value string, protocols ...string) bool { |
||
9 | return validate.URL(value, protocols...) == nil |
||
10 | } |
||
11 | |||
12 | // RelativeURL is used to check that value is a valid absolute or relative URL string. The protocol is considered |
||
13 | // optional when validating the syntax of the given URL. This means that both http:// and https:// are valid |
||
14 | // but also relative URLs that contain no protocol (e.g. //example.com). By default, the function checks |
||
15 | // only for the http:// and https:// protocols. Use the protocols argument to configure |
||
16 | // the list of expected protocols. |
||
17 | func RelativeURL(value string, protocols ...string) bool { |
||
18 | return validate.RelativeURL(value, protocols...) == nil |
||
19 | } |
||
20 |