aboutsummaryrefslogtreecommitdiffstats
path: root/core.go
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2012-04-18 22:07:52 -0400
committerbnewbold <bnewbold@robocracy.org>2012-04-18 22:07:52 -0400
commitb85e202511ea821c773f5eeb305ff71f040fc098 (patch)
tree609c05bf13aeb1bf6ee458f58d600d00d4661d87 /core.go
parent6023bb2fe3759dc01e608ed056e843b1f731acf0 (diff)
downloadbommom-b85e202511ea821c773f5eeb305ff71f040fc098.tar.gz
bommom-b85e202511ea821c773f5eeb305ff71f040fc098.zip
tweaks, basic loading
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}