aboutsummaryrefslogtreecommitdiffstats
path: root/core.go
diff options
context:
space:
mode:
Diffstat (limited to 'core.go')
-rw-r--r--core.go22
1 files changed, 22 insertions, 0 deletions
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}