Skip to content

Commit

Permalink
Merge pull request #17 from spenczar/must-parse
Browse files Browse the repository at this point in the history
Add MustParseSchema function
  • Loading branch information
serejja committed Mar 24, 2015
2 parents ab31b48 + 2613443 commit 5c8e29f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,16 @@ func ParseSchemaWithRegistry(rawSchema string, schemas map[string]Schema) (Schem
return schemaByType(schema, schemas)
}

// MustParseSchema is like ParseSchema, but panics if the given schema
// cannot be parsed.
func MustParseSchema(rawSchema string) Schema {
s, err := ParseSchema(rawSchema)
if err != nil {
panic(err)
}
return s
}

func schemaByType(i interface{}, registry map[string]Schema) (Schema, error) {
switch v := i.(type) {
case nil:
Expand Down

0 comments on commit 5c8e29f

Please sign in to comment.