func (c *Community) Validate() error {
	if err := c.updateLatLng(); err != nil {
		return err
	}
	if valid, errMap := val.Struct(c); !valid {
		return ErrorFromMap(errMap)
	}
	return nil
}
示例#2
0
func (f *Feed) Validate() error {
	if valid, errMap := val.Struct(f); !valid {
		return ErrorFromMap(errMap)
	}
	return nil
}
示例#3
0
func (t *Token) Validate() error {
	if valid, errMap := val.Struct(t); !valid {
		return val.ErrorFromMap(errMap)
	}
	return nil
}
示例#4
0
func (story *Story) Validate() error {
	if valid, errMap := val.Struct(story); !valid {
		return ErrorFromMap(errMap)
	}
	return nil
}
示例#5
0
func (m *Member) Validate() error {
	if valid, errMap := val.Struct(m); !valid {
		return ErrorFromMap(errMap)
	}
	return nil
}
示例#6
0
func (c *Category) Validate() error {
	if valid, errMap := val.Struct(c); !valid {
		return ErrorFromMap(errMap)
	}
	return nil
}
	testStruct4{14, 400, -10.0000, 18},
	testStruct4{19, 99, -10.0000, 18},
	testStruct4{19, 400, 19.90000001, 18},
	testStruct4{19, 400, -10.0000, 19},
	testStruct5{[]int{19, 20, 10}},
	testStruct6{90.1, -180.0},
	testStruct6{90.0, -180.1},
}

var _ = Describe("Struct", func() {

	Describe("Valid", func() {

		It("should be valid for the values", func() {
			for _, v := range validStructs {
				_, errs := val.Struct(v)
				Expect(errs).To(BeEmpty())
			}
		})
	})

	Describe("Invalid", func() {

		It("should be invalid for the values", func() {
			for _, v := range invalidStructs {
				valid, _ := val.Struct(v)
				Expect(valid).To(BeFalse())
			}
		})
	})
})