schema/field: Allow .Unique() definition on int / float fields

Reviewed By: a8m

Differential Revision: D16891088

fbshipit-source-id: b3d8375685b6d1957f678c2f9eb40e172891b255
This commit is contained in:
Alex Snast
2019-08-19 06:34:11 -07:00
committed by Facebook Github Bot
parent 7438104b5d
commit a209a8395e
21 changed files with 641 additions and 70 deletions

View File

@@ -190,6 +190,12 @@ type intBuilder struct {
Field
}
// Unique makes the field unique within all vertices of this type.
func (b *intBuilder) Unique() *intBuilder {
b.unique = true
return b
}
// Range adds a range validator for this field where the given value needs to be in the range of [i, j].
func (b *intBuilder) Range(i, j int) *intBuilder {
b.validators = append(b.validators, func(v int) error {
@@ -275,6 +281,12 @@ type floatBuilder struct {
Field
}
// Unique makes the field unique within all vertices of this type.
func (b *floatBuilder) Unique() *floatBuilder {
b.unique = true
return b
}
// Range adds a range validator for this field where the given value needs to be in the range of [i, j].
func (b *floatBuilder) Range(i, j float64) *floatBuilder {
b.validators = append(b.validators, func(v float64) error {