schema/field: add NotEmpty built-in validator to bytes fields (#1869)

* added MaxLen built-in validator to `[]byte`

* typo

* move test to type_test.go

* Update doc/md/schema-fields.md

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

* added min len validator to bytes

* fix tests
go generate

* CR

* add not empty validator

* CR

* doc/md:  add doc on `NotEmpty` bytes validator

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
This commit is contained in:
Amit Shani
2021-08-24 14:47:15 +03:00
committed by GitHub
parent ac0bd65145
commit 60e726812b
2 changed files with 7 additions and 0 deletions

View File

@@ -600,6 +600,12 @@ func (b *bytesBuilder) MinLen(i int) *bytesBuilder {
return b
}
// NotEmpty adds a length validator for this field.
// Operation fails if the length of the buffer is zero.
func (b *bytesBuilder) NotEmpty() *bytesBuilder {
return b.MinLen(1)
}
// Validate adds a validator for this field. Operation fails if the validation fails.
//
// field.Bytes("blob").