chainlist / svelte-forms

Svelte forms validation made easy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Can not programatically set field value to null

tbydza opened this issue · comments

I need to set field value programatically, but sometimes the value is null or undefined.

// example
const name = field('name', '');
name.set(null);

If I call set method with null parameter it causes this error:

TypeError: Cannot convert undefined or null to object

It is caused by const keys = Object.keys(field); in function isField .

Is it feature or bug?
I can work around it with this:

const fieldObj = get(name);
fieldObject.value = null;
name.set(fieldObj);

But it seems unnecessarily complicated.