Passed
Pull Request — main (#38)
by Igor
01:51
created

validate_test.ExampleURL_urlWithoutProtocol   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 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:
54
	// invalid
55
}
56