mirror of
https://github.com/ent/ent.git
synced 2026-03-05 19:35:23 +03:00
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:
@@ -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").
|
||||
|
||||
Reference in New Issue
Block a user