fix: allow decimal inputs for number fields
Fixes #430 (original issue #186).
I attempted to add a regression test within `formEngine.test.ts`, however the step is an actual HTML input prop, not part of the formEngine validation. Testing of HTML inputs in this way would require Svelte component testing or higher level e2e testing which doesn't seem to be set up, if I missed it please let me know.
For reference this test passes with current code (bugged):
```ts
it("should accept decimal numbers for number fields", () => {
const onSubmitMock = jest.fn();
const formEngine = makeFormEngine({
onSubmit: onSubmitMock,
onCancel: console.log,
});
const numberField = formEngine.addField({ name: "decimalField" });
numberField.value.set(1.5);
formEngine.triggerSubmit();
expect(onSubmitMock).toHaveBeenCalledWith({
decimalField: 1.5,
});
expect(get(formEngine.isValid)).toBe(true);
expect(get(numberField.errors)).toStrictEqual([]);
});
```
合并状态:未合并 关闭于 2025-11-20 2 条评论