mirror of
https://github.com/ent/ent.git
synced 2026-04-28 05:30:56 +03:00
schema/field: Allow .Unique() definition on int / float fields
Reviewed By: a8m Differential Revision: D16891088 fbshipit-source-id: b3d8375685b6d1957f678c2f9eb40e172891b255
This commit is contained in:
committed by
Facebook Github Bot
parent
7438104b5d
commit
a209a8395e
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user