Passed
Push — main ( 819916...3f29c3 )
by Igor
566:22 queued 490:35
created

validation_test.ExampleSequentially   A

Complexity

Conditions 2

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 10
nop 0
dl 0
loc 14
rs 9.9
c 0
b 0
f 0
1
package validation_test
2
3
import (
4
	"fmt"
5
6
	"github.com/muonsoft/validation"
7
	"github.com/muonsoft/validation/it"
8
	"github.com/muonsoft/validation/validator"
9
)
10
11
func ExampleSequentially() {
12
	title := "bar"
13
14
	err := validator.ValidateString(
15
		&title,
16
		validation.Sequentially(
17
			it.IsBlank(),
18
			it.HasMinLength(5),
19
		),
20
	)
21
22
	violations := err.(validation.ViolationList)
23
	for _, violation := range violations {
24
		fmt.Println(violation.Error())
25
	}
26
	// Output:
27
	// violation: This value should be blank.
28
}
29