//
// Validate - checks for missing required fields, etc
//
345109
func (pTypeDef *TimestampTest) Validate() error {
	if pTypeDef.Mytime.IsZero() {
		return fmt.Errorf("TimestampTest: Missing required field: mytime")
	}
	return nil
}
1187577
func (e Error) Validate(v interface{}) error {
	if e.Message == "" {
		return fmt.Errorf("invalid error message %q", e.Message)
	}

	if e.Code <= 0 {
		return fmt.Errorf("invalid error code %d", e.Code)
	}

	return nil
}
1012211
func (m *CheckRequest) Validate() error {
	if m == nil {
		return nil
	}

	{
		tmp := m.GetAttributes()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return CheckRequestValidationError{
					field:  "Attributes",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	return nil
}
1128547
func (s *SnapshotDeleteService) Validate() error {
	var invalid []string
	if s.repository == "" {
		invalid = append(invalid, "Repository")
	}
	if s.snapshot == "" {
		invalid = append(invalid, "Snapshot")
	}
	if len(invalid) > 0 {
		return fmt.Errorf("missing required fields: %v", invalid)
	}
	return nil
}
1196899
func (pTypeDef *Test) Validate() error {
	if pTypeDef.Name == "" {
		return fmt.Errorf("Test: Missing required field: name")
	}
	if pTypeDef.Utfname == "" {
		return fmt.Errorf("Test: Missing required field: utfname")
	}
	if pTypeDef.My_int_array == nil {
		return fmt.Errorf("Test: Missing required field: my_int_array")
	}
	if pTypeDef.My_str_array == nil {
		return fmt.Errorf("Test: Missing required field: my_str_array")
	}
	fmt.Println("myuuid:", pTypeDef.Myuuid)
	if pTypeDef.Myuuid == nil {
		return fmt.Errorf("Test: Missing required field: myuuid")
	}
	if pTypeDef.Myaz == "" {
		return fmt.Errorf("Test: Missing required field: myaz")
	}
	if pTypeDef.Mytime.IsZero() {
		return fmt.Errorf("Test: Missing required field: mytime")
	}
	if pTypeDef.Co1 == "" {
		return fmt.Errorf("Test: Missing required field: co1")
	}
	if pTypeDef.Co2 == "" {
		return fmt.Errorf("Test: Missing required field: co2")
	}
	if pTypeDef.Co3 == "" {
		return fmt.Errorf("Test: Missing required field: co3")
	}
	if pTypeDef.Symtest == nil {
		return fmt.Errorf("Test: Missing required field: symtest")
	}
	return nil
}
549930
func (m *RequirementRule) Validate() error {
	if m == nil {
		return nil
	}

	if m.GetMatch() == nil {
		return RequirementRuleValidationError{
			field:  "Match",
			reason: "value is required",
		}
	}

	{
		tmp := m.GetMatch()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return RequirementRuleValidationError{
					field:  "Match",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	{
		tmp := m.GetRequires()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return RequirementRuleValidationError{
					field:  "Requires",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	return nil
}
983315
func (config Config) validate() error {
	if config.Collection == "" {
		return errors.New("missing collection")
	}
	if config.Mongo == nil {
		return errors.New("missing mongo client")
	}
	return nil
}
327475
func (e *RequiredValidator) Validate(s interface{}) error {
	if e.TagName == "" {
		e.TagName = "required"
	}

	if e.TagValue == "" {
		e.TagValue = "true"
	}

	for _, field := range structs.Fields(s) {
		if err := e.processField("", field); err != nil {
			return err
		}
	}

	return nil
}
902559
func (t *TextInput) Validate() error {
	if t.Description == "" {
		return errors.New(ErrValidation, errorMessages, "text input description must not be empty")
	}
	if _, err := url.Parse(t.Link); err != nil {
		return errors.Annotate(err, ErrParsing, errorMessages, "text input link")
	}
	if t.Name == "" {
		return errors.New(ErrValidation, errorMessages, "text input name must not be empty")
	}
	if t.Title == "" {
		return errors.New(ErrValidation, errorMessages, "text input title must not be empty")
	}
	return nil
}
742525
func (m *Matcher) Validate() error {
	if !m.Name.IsValid() {
		return fmt.Errorf("invalid name %q", m.Name)
	}
	if m.IsRegex {
		if _, err := regexp.Compile(m.Value); err != nil {
			return fmt.Errorf("invalid regular expression %q", m.Value)
		}
	} else if !LabelValue(m.Value).IsValid() || len(m.Value) == 0 {
		return fmt.Errorf("invalid value %q", m.Value)
	}
	return nil
}
741198
func (a *APS) Validate() error {
	if a == nil {
		return ErrIncomplete
	}

	// must have a body or a badge (or custom data)
	if len(a.Alert.Body) == 0 && a.Badge == badge.Preserve {
		return ErrIncomplete
	}
	return nil
}
807763
func (pTypeDef *SymTest) Validate() error {
	if pTypeDef.Symmap == nil {
		return fmt.Errorf("SymTest: Missing required field: symmap")
	}
	if pTypeDef.Symary == nil {
		return fmt.Errorf("SymTest: Missing required field: symary")
	}
	if pTypeDef.Sym == "" {
		return fmt.Errorf("SymTest: Missing required field: sym")
	}
	return nil
}
96256
func (s *SnapshotGetService) Validate() error {
	var invalid []string
	if s.repository == "" {
		invalid = append(invalid, "Repository")
	}
	if len(invalid) > 0 {
		return fmt.Errorf("missing required fields: %v", invalid)
	}
	return nil
}
1043783
func (v *StringRule) Validate(value interface{}) error {
	value, isNil := Indirect(value)
	if isNil || IsEmpty(value) {
		return nil
	}

	str, err := EnsureString(value)
	if err != nil {
		return err
	}

	if v.validate(str) {
		return nil
	}
	return errors.New(v.message)
}
741598
func (d *FieldData) Validate() error {
	var result *multierror.Error

	// Scan for missing required fields
	for field, schema := range d.Schema {
		if schema.Required {
			_, ok := d.Raw[field]
			if !ok {
				result = multierror.Append(result, fmt.Errorf(
					"field %q is required", field))
			}
		}
	}

	// Validate field type and value
	for field, value := range d.Raw {
		schema, ok := d.Schema[field]
		if !ok {
			result = multierror.Append(result, fmt.Errorf(
				"%q is an invalid field", field))
			continue
		}

		switch schema.Type {
		case TypeBool, TypeInt, TypeMap, TypeArray, TypeString:
			val, _, err := d.getPrimitive(field, schema)
			if err != nil {
				result = multierror.Append(result, fmt.Errorf(
					"field %q with input %q doesn't seem to be of type %s",
					field, value, schema.Type))
			}
			// Check that we don't have an empty value for required fields
			if schema.Required && val == schema.Type.Zero() {
				result = multierror.Append(result, fmt.Errorf(
					"field %q is required, but no value was found", field))
			}
		default:
			result = multierror.Append(result, fmt.Errorf(
				"unknown field type %s for field %s", schema.Type, field))
		}
	}

	return result.ErrorOrNil()
}
1286924
func (field *RelationalFieldDefinition) Validate() *dslengine.ValidationErrors {
	fmt.Println("Validing Field")
	verr := new(dslengine.ValidationErrors)

	if field.Parent == nil {
		verr.Add(field, "missing relational model parent")
	}
	if field.FieldName == "" {
		verr.Add(field, "field name not defined")
	}
	return verr.AsError()
}
621278
func (pTypeDef *StringTest) Validate() error {
	if pTypeDef.Name == "" {
		return fmt.Errorf("StringTest: Missing required field: name")
	}
	if pTypeDef.Parent == "" {
		return fmt.Errorf("StringTest: Missing required field: parent")
	}
	return nil
}