func (n *Note) Validate() error {
	if n.ID == "" {
		return errors.New("id required")
	}
	if !strings.HasPrefix(n.ID, "note-") {
		return errors.New("incorrect doc type")
	}
	if !n.unmarshaling {
		if err := n.validateModel(n.Model); err != nil {
			return err
		}
	}
	if n.Created.IsZero() {
		return errors.New("created time required")
	}
	if n.Modified.IsZero() {
		return errors.New("modified time required")
	}
	if n.Attachments == nil {
		return errors.New("attachments collection must not be nil")
	}
	for i, fv := range n.FieldValues {
		if !n.unmarshaling {
			switch n.Model.Fields[i].Type {
			case TextField:
				if fv.files != nil {
					return errors.Errorf("text field %d must not have file list", i)
				}
			case AudioField:
				if fv.Text != "" {
					return errors.Errorf("audio field %d must not have text", i)
				}
			case ImageField:
				if fv.Text != "" {
					return errors.Errorf("image field %d must not have text", i)
				}
			}
		}
		if fv != nil && fv.files != nil && !n.Attachments.hasMemberView(fv.files) {
			return errors.Errorf("field %d file list must be member of attachments collection", i)
		}
	}
	return nil
}
// Validate validates that all of the data in the note  appears valid and self
// consistent. A nil return value means no errors were detected.
Validate validates that all of the data in the note  appears valid and self
consistent. A nil return value means no errors were detected.
// Validate validates that all of the data in the note appears valid and self // consistent . A nil return value means no errors were detected .
func (n *Note) Validate() error {
	if n.ID == "" {
		return errors.New("id required")
	}
	if !strings.HasPrefix(n.ID, "note-") {
		return errors.New("incorrect doc type")
	}
	if !n.unmarshaling {
		if err := n.validateModel(n.Model); err != nil {
			return err
		}
	}
	if n.Created.IsZero() {
		return errors.New("created time required")
	}
	if n.Modified.IsZero() {
		return errors.New("modified time required")
	}
	if n.Attachments == nil {
		return errors.New("attachments collection must not be nil")
	}
	for i, fv := range n.FieldValues {
		if !n.unmarshaling {
			switch n.Model.Fields[i].Type {
			case TextField:
				if fv.files != nil {
					return errors.Errorf("text field %d must not have file list", i)
				}
			case AudioField:
				if fv.Text != "" {
					return errors.Errorf("audio field %d must not have text", i)
				}
			case ImageField:
				if fv.Text != "" {
					return errors.Errorf("image field %d must not have text", i)
				}
			}
		}
		if fv != nil && fv.files != nil && !n.Attachments.hasMemberView(fv.files) {
			return errors.Errorf("field %d file list must be member of attachments collection", i)
		}
	}
	return nil
}
func ( n * Note ) Validate ( ) error { if n . ID == " " { return errors . New ( " " ) } if ! strings . HasPrefix ( n . ID , " " ) { return errors . New ( " " ) } if ! n . unmarshaling { if err := n . validateModel ( n . Model ) ; err != nil { return err } } if n . Created . IsZero ( ) { return errors . New ( " " ) } if n . Modified . IsZero ( ) { return errors . New ( " " ) } if n . Attachments == nil { return errors . New ( " " ) } for i , fv := range n . FieldValues { if ! n . unmarshaling { switch n . Model . Fields [ i ] . Type { case TextField : if fv . files != nil { return errors . Errorf ( " " , i ) } case AudioField : if fv . Text != " " { return errors . Errorf ( " " , i ) } case ImageField : if fv . Text != " " { return errors . Errorf ( " " , i ) } } } if fv != nil && fv . files != nil && ! n . Attachments . hasMemberView ( fv . files ) { return errors . Errorf ( " " , i ) } } return nil }
Validate validates that all of the data in the note  appears valid and self
consistent.
Validate validates that all of the data in the note appears valid and self consistent .