FIX: use field_name instead of name to avoid colliding with the name field.

This commit is contained in:
Jeremy Wall 2019-04-17 23:02:18 -05:00
parent 524f85102f
commit 7846c631d0
2 changed files with 11 additions and 4 deletions

View File

@ -101,9 +101,9 @@ let shaped = module {
},
};
let shape_tuple_handler = func (acc, name, value) => acc{
ok = select (name) in acc.val, false, {
true = schema.shaped{val=value, shape=acc.val.(name), partial=false},
let shape_tuple_handler = func (acc, field_name, value) => acc{
ok = select (field_name) in acc.val, false, {
true = schema.shaped{val=value, shape=acc.val.(field_name), partial=false},
},
};

View File

@ -92,7 +92,7 @@ assert t.ok{
};
assert t.ok{
test = schema.shaped{val={foo="bar", count=1}, shape={foo=""}},
test = schema.shaped{val={foo="bar", count=1, fuzzy={bear="claws"}}, shape={foo=""}},
desc = "shaped for partial tuples works",
};
@ -170,3 +170,10 @@ assert t.not_ok{
test = schema.all{val={foo="bar", baz="quux"}, types=[{foo=""}, {baz=""}, {quux=""}]},
desc = "all enforces that all of the valid shapes must be partial matches (fail)",
};
assert t.ok{
test = schema.shaped{val={
name = "simple",
}, shape={name="",}, partial=true},
desc = "partial shapes match okay",
};