Beispiel #1
0
func (self *Form) IsFieldHidden(metaData *model.MetaData) bool {
	if metaData.BoolAttrib("hidden") {
		return true
	}
	selector := metaData.Selector()
	wildcardSelector := metaData.WildcardSelector()
	return utils.StringIn(selector, self.HiddenFields) || utils.StringIn(wildcardSelector, self.HiddenFields)
}
Beispiel #2
0
func (self *Form) IsFieldDisabled(metaData *model.MetaData) bool {
	if metaData.BoolAttrib("disabled") {
		return true
	}
	selector := metaData.Selector()
	wildcardSelector := metaData.WildcardSelector()
	return utils.StringIn(selector, self.DisabledFields) || utils.StringIn(wildcardSelector, self.DisabledFields)
}
Beispiel #3
0
func (self *Form) IsFieldRequired(metaData *model.MetaData) bool {
	if val, ok := metaData.ModelValue(); ok && val.Required(metaData) {
		return true
	}
	selector := metaData.Selector()
	wildcardSelector := metaData.WildcardSelector()
	return utils.StringIn(selector, self.RequiredFields) || utils.StringIn(wildcardSelector, self.RequiredFields)
}
Beispiel #4
0
func (self *MultipleChoice) Validate(metaData *MetaData) error {
	options := self.Options(metaData)
	if len(options) == 0 {
		return errs.Format("model.MultipleChoice needs options")
	}
	for _, option := range options {
		if option == "" {
			return errs.Format("model.MultipleChoice options must not be empty strings")
		}
	}
	for _, str := range *self {
		if !utils.StringIn(str, options) {
			return &InvalidChoice{str, options}
		}
	}
	return nil
}
Beispiel #5
0
func (self *MetaData) SelectorsMatch(list []string) bool {
	return utils.StringIn(self.Selector(), list) || utils.StringIn(self.WildcardSelector(), list)
}
Beispiel #6
0
func (self *Form) IsFieldExcluded(metaData *model.MetaData) bool {
	selector := metaData.Selector()
	wildcardSelector := metaData.WildcardSelector()
	return utils.StringIn(selector, self.ExcludedFields) || utils.StringIn(wildcardSelector, self.ExcludedFields)
}
Beispiel #7
0
func (self *Form) isFieldRequiredSelectors(metaData *model.MetaData, selector, wildcardSelector string) bool {
	if metaData.BoolAttrib("required") {
		return true
	}
	return utils.StringIn(selector, self.RequiredFields) || utils.StringIn(wildcardSelector, self.RequiredFields)
}
Beispiel #8
0
func (self *MultipleChoice) IsSet(option string) bool {
	return utils.StringIn(option, self.Get())
}