diff --git a/std/schema.ucg b/std/schema.ucg index d65d6c5..4132e0a 100644 --- a/std/schema.ucg +++ b/std/schema.ucg @@ -26,6 +26,8 @@ let must = func (m, msg) => select m, fail msg, { // Any does a boolean match against a set of allowed shapes for a type. // This module uses the shape module below so the same rules for checking // the types against the source value apply for each example in the list. +// +// This module does not do partial matches for the shapes. let any = module { // The source value to check. val=NULL, @@ -35,7 +37,7 @@ let any = module { let schema = mod.pkg(); let reducer = func (acc, t) => acc{ - ok = acc.ok || (schema.shaped{val=acc.val, shape=t}), + ok = acc.ok || (schema.shaped{val=acc.val, shape=t, partial=false}), }; let any = func (val, types) => reduce(reducer, {ok=false, val=val}, types); diff --git a/std/tests/schema_test.ucg b/std/tests/schema_test.ucg index d83ad55..aae6051 100644 --- a/std/tests/schema_test.ucg +++ b/std/tests/schema_test.ucg @@ -135,3 +135,8 @@ assert t.not_ok{ test = schema.shaped{val={foo="bar"}, shaped=1.0}, desc = "a tuple is not a float", }; + +assert t.not_ok{ + test = schema.any{val={foo="bar", quux="baz"}, types=[1.0, {foo="bar", qux="baz"}]}, + desc = "any doesn't match against missing fields for tuples.", +}; \ No newline at end of file