示例#1
0
				})
				Context("and the parent is required", func() {
					BeforeEach(func() {
						validation = &dslengine.ValidationDefinition{
							Required: []string{"foo"},
						}
					})
					It("checks the child & parent object are not nil", func() {
						Ω(code).Should(Equal(embeddedRequiredValCode))
					})
				})
				Context("with a child attribute with struct:tag:name metadata", func() {
					const fieldTag = "FOO"

					BeforeEach(func() {
						catt.Metadata = dslengine.MetadataDefinition{"struct:field:name": []string{fieldTag}}
						ccatt.Metadata = nil
						validation = nil
					})

					It("produces the validation go code using the field tag", func() {
						Ω(code).Should(Equal(strings.Replace(tagCode, "__tag__", fieldTag, -1)))
					})
				})
				Context("with a grand child attribute with struct:tag:name metadata", func() {
					const fieldTag = "FOO"

					BeforeEach(func() {
						catt.Metadata = nil
						ccatt.Metadata = dslengine.MetadataDefinition{"struct:field:name": []string{fieldTag}}
						validation = nil