From b85e202511ea821c773f5eeb305ff71f040fc098 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Wed, 18 Apr 2012 22:07:52 -0400 Subject: tweaks, basic loading --- core.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'core.go') diff --git a/core.go b/core.go index 087a3f4..1d6debd 100644 --- a/core.go +++ b/core.go @@ -77,6 +77,28 @@ func (b *Bom) AddLineItem(li *LineItem) error { return nil } +func (b *Bom) Validate() error { + if !isShortName(b.Version) { + return Error("version not a ShortName: \"" + b.Version + "\"") + } + // TODO: nil? what is zero of Time? + nullTime := time.Time{} + if b.Created == nullTime { + return Error("created timestamp not defined") + } + return nil +} + +func (bs *BomStub) Validate() error { + if !isShortName(bs.Name) { + return Error("name not a ShortName: \"" + bs.Name + "\"") + } + if !isShortName(bs.Owner) { + return Error("owner name not a ShortName: \"" + bs.Owner + "\"") + } + return nil +} + // ---------- testing func makeTestBom() *Bom { op1 := OfferPrice{Currency: "usd", Price: 1.0, MinQty: 1} -- cgit v1.2.3