~chrisppy/beagles

ddf1196a536af564692678402dd3f44358774af0 — Chris Palmer 28 days ago ee6782d bare
Validate on write too
1 files changed, 9 insertions(+), 0 deletions(-)

M fmsg/fmsg.go
M fmsg/fmsg.go => fmsg/fmsg.go +9 -0
@@ 112,6 112,15 @@ func (m *Message) validate() map[error]bool {

// Message will convert the structure to Fmsg format
func (m *Message) Message() ([]byte, error) {
	errs := m.validate()
	if len(errs) > 0 {
		e := ""
		for err := range errs {
			e = fmt.Sprintf("%s\n%s", e, err.Error())
		}
		return nil, fmt.Errorf(e)
	}

	return bare.Marshal(m)
}