Commit 1b282cfa authored by Eric Myhre's avatar Eric Myhre

schema: connect validation, Compile() now works.

More rules are still to come.
parent b6009032
......@@ -66,8 +66,21 @@ func (c *Compiler) Init() {
}
}
func (c *Compiler) Compile() (*TypeSystem, error) {
panic("TODO")
func (c *Compiler) Compile() (*TypeSystem, []error) {
var errs []error
for _, typ := range c.ts.list {
validate(c.ts, typ, &errs)
}
// TODO sort ts.anonTypes
for _, typ := range c.ts.anonTypes {
validate(c.ts, typ, &errs)
}
if errs != nil {
return nil, errs
}
result := c.ts
c.ts = nil // result shall now be immutable
return result, nil
}
func (c *Compiler) MustCompile() *TypeSystem {
......
......@@ -10,7 +10,7 @@ import (
// and so we've just chained it all together with switch statements;
// creating a separate interface per result type seems just not super relevant.
func (schdmt Schema) Compile() (*schema.TypeSystem, error) {
func (schdmt Schema) Compile() (*schema.TypeSystem, []error) {
c := &schema.Compiler{}
typesdmt := schdmt.FieldTypes()
for itr := typesdmt.Iterator(); !itr.Done(); {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment