Skip to content

Commit 4dfcee4

Browse files
committed
fix: default encoding
1 parent e7abdeb commit 4dfcee4

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

packages/vue-components/__tests__/OmegaForm/WithDefaultConstructorPersistency.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@ describe("OmegaForm withDefaultConstructor with persistency", () => {
2424
addForm: null,
2525
b: S.PositiveNumber(100)
2626
}))),
27-
fifth: S.Email
27+
fifth: S.Email,
28+
sixth: S.NumberFromString.pipe(S.withDefaultConstructor(() => 1000))
2829
})
2930

3031
// Simulate query string parameters
3132
// The persistency key is based on pathname and schema keys
3233
// Format: pathname-key1-key2-key3...
3334
// Keys from meta will be flattened with dot notation for nested fields
3435
const pathname = "/test"
35-
const keys = ["first", "second", "third", "fourth.addForm", "fourth.b", "fifth"]
36+
const keys = ["first", "second", "third", "fourth.addForm", "fourth.b", "fifth", "sixth"]
3637
const persistencyKey = `${pathname}-${keys.join("-")}`
3738
const queryValue = JSON.stringify({ first: 1234 })
3839

@@ -95,7 +96,8 @@ describe("OmegaForm withDefaultConstructor with persistency", () => {
9596
fourth: {
9697
addForm: null,
9798
b: 100 // Default from withDefaultConstructor
98-
}
99+
},
100+
sixth: "1000"
99101
})
100102
})
101103
})

packages/vue-components/stories/OmegaForm/SimpleFormVuetifyDefault.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<template>
22
<form.Form :subscribe="['values']">
33
<template #default="{ subscribedValues: { values } }">
4+
<form.Input
5+
label="aString"
6+
name="aString"
7+
/>
48
<form.Input
59
label="bString"
610
name="bString"
@@ -18,11 +22,11 @@ import { S } from "effect-app"
1822
import { useOmegaForm } from "../../src"
1923
2024
const schema = S.Struct({
21-
bString: S.PositiveNumber.pipe(S.withDefaultConstructor(() => S.PositiveNumber(2.0)))
22-
// aString: S.NullOr(S.NonEmptyString).withDefault
25+
aString: S.NullOr(S.NonEmptyString255).withDefault,
26+
bString: S.NullOr(S.NonEmptyString255).withDefault
2327
})
2428
const defaultValues = {
25-
bString: -2
29+
aString: ""
2630
}
2731
const form = useOmegaForm(schema, {
2832
onSubmit: async (values) => {

packages/vue-components/stories/OmegaForm/WithDefaultConstructor.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<template #default="{ subscribedValues: { errors, values: vvv } }">
77
<div>Errors: {{ errors }}</div>
88
<div>Values: {{ vvv }}</div>
9+
<addForm.Input name="first" />
910
</template>
1011
</addForm.Form>
1112
</template>
@@ -29,7 +30,8 @@ const AddSchema = S.Struct({
2930
addForm: null,
3031
b: S.PositiveNumber(100)
3132
}))),
32-
fifth: S.Email
33+
fifth: S.Email,
34+
sixth: S.NumberFromString.pipe(S.withDefaultConstructor(() => 1000))
3335
})
3436
3537
const addForm = useOmegaForm(

0 commit comments

Comments
 (0)