Passed
Pull Request — main (#37)
by Rushan
02:17
created

examples_sequentially_validation_test.go   A

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 16
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validation_test.ExampleValidator_Validate_validationInterruptedAtFirstViolation 0 14 2
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 ExampleValidator_Validate_validationInterruptedAtFirstViolation() {
12
	title := "aaa"
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