Total Lines | 52 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package validate_test |
||
2 | |||
3 | import ( |
||
4 | "fmt" |
||
5 | |||
6 | "github.com/muonsoft/validation/validate" |
||
7 | ) |
||
8 | |||
9 | func ExampleURL_validAbsoluteURL() { |
||
10 | err := validate.URL("https://example.com") |
||
11 | |||
12 | fmt.Println(err) |
||
13 | // Output: |
||
14 | // <nil> |
||
15 | } |
||
16 | |||
17 | func ExampleURL_validURLWithCustomProtocol() { |
||
18 | err := validate.URL("ftp://example.com", "http", "https", "ftp") |
||
19 | |||
20 | fmt.Println(err) |
||
21 | // Output: |
||
22 | // <nil> |
||
23 | } |
||
24 | |||
25 | func ExampleURL_urlWithoutProtocol() { |
||
26 | err := validate.URL("example.com") |
||
27 | |||
28 | fmt.Println(err) |
||
29 | // Output: |
||
30 | // unexpected protocol |
||
31 | } |
||
32 | |||
33 | func ExampleURL_invalidURL() { |
||
34 | err := validate.URL("http:// example.com/") |
||
35 | |||
36 | fmt.Println(err) |
||
37 | // Output: |
||
38 | // parse "http:// example.com/": invalid character " " in host name |
||
39 | } |
||
40 | |||
41 | func ExampleRelativeURL_validRelativeURL() { |
||
42 | err := validate.RelativeURL("//example.com") |
||
43 | |||
44 | fmt.Println(err) |
||
45 | // Output: |
||
46 | // <nil> |
||
47 | } |
||
48 | |||
49 | func ExampleRelativeURL_invalidURL() { |
||
50 | err := validate.RelativeURL("example.com") |
||
51 | |||
52 | fmt.Println(err) |
||
53 | // Output: |
||
56 |