| Conditions | 2 |
| Total Lines | 15 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | package validation_test |
||
| 10 | func ExampleNewCustomStringConstraint() { |
||
| 11 | validate := func(s string) bool { |
||
| 12 | return s == "valid" |
||
| 13 | } |
||
| 14 | constraint := validation.NewCustomStringConstraint( |
||
| 15 | validate, |
||
| 16 | "ExampleConstraint", // constraint name |
||
| 17 | "exampleCode", // violation code |
||
| 18 | "Unexpected value.", // violation message template |
||
| 19 | ) |
||
| 20 | |||
| 21 | s := "foo" |
||
| 22 | err := validator.ValidateString(&s, constraint) |
||
| 23 | |||
| 24 | fmt.Println(err) |
||
| 25 | // Output: |
||
| 28 |