policyengine-household-wizard 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -4
- package/dist/{index-B_OXaS4a.cjs → index-BfoPBFne.cjs} +1 -1
- package/dist/index-CIL8FXNR.cjs +1 -0
- package/dist/{index-DWM0giHt.js → index-DoD0AXHz.js} +72 -70
- package/dist/index-fgLnXugs.js +225 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/primitives/index.d.ts +12 -12
- package/dist/primitives/useWizardSteps.d.ts +1 -1
- package/dist/primitives.d.ts +1 -1
- package/dist/uk-household/adapters/householdImpactRequest.d.ts +91 -0
- package/dist/uk-household/adapters/householdImpactRequest.d.ts.map +1 -0
- package/dist/uk-household/adapters/index.d.ts +2 -0
- package/dist/uk-household/adapters/index.d.ts.map +1 -0
- package/dist/uk-household/children.d.ts +18 -0
- package/dist/uk-household/children.d.ts.map +1 -0
- package/dist/uk-household/codes.d.ts +22 -0
- package/dist/uk-household/codes.d.ts.map +1 -0
- package/dist/uk-household/defaults.d.ts +56 -0
- package/dist/uk-household/defaults.d.ts.map +1 -0
- package/dist/uk-household/draft.d.ts +37 -0
- package/dist/uk-household/draft.d.ts.map +1 -0
- package/dist/uk-household/index.d.ts +10 -0
- package/dist/uk-household/index.d.ts.map +1 -0
- package/dist/uk-household/serialize.d.ts +4 -0
- package/dist/uk-household/serialize.d.ts.map +1 -0
- package/dist/uk-household/statePension.d.ts +42 -0
- package/dist/uk-household/statePension.d.ts.map +1 -0
- package/dist/uk-household/types.d.ts +134 -0
- package/dist/uk-household/types.d.ts.map +1 -0
- package/dist/uk-household/validate.d.ts +59 -0
- package/dist/uk-household/validate.d.ts.map +1 -0
- package/dist/uk-household-adapters.cjs +1 -0
- package/dist/uk-household-adapters.d.ts +1 -0
- package/dist/uk-household-adapters.js +5 -0
- package/dist/uk-household.cjs +1 -0
- package/dist/uk-household.d.ts +1 -0
- package/dist/uk-household.js +220 -0
- package/dist/us-household/adapters/index.d.ts +1 -1
- package/dist/us-household/adapters/v1Payload.d.ts +1 -1
- package/dist/us-household/adapters/v1Payload.d.ts.map +1 -1
- package/dist/us-household/draft.d.ts +1 -1
- package/dist/us-household/draft.d.ts.map +1 -1
- package/dist/us-household/index.d.ts +9 -9
- package/dist/us-household/normalize.d.ts +1 -1
- package/dist/us-household/normalize.d.ts.map +1 -1
- package/dist/us-household/serialize.d.ts +1 -1
- package/dist/us-household/serialize.d.ts.map +1 -1
- package/dist/us-household/types.d.ts +9 -14
- package/dist/us-household/types.d.ts.map +1 -1
- package/dist/us-household/validate.d.ts +1 -1
- package/dist/us-household/validate.d.ts.map +1 -1
- package/dist/us-household-adapters.cjs +1 -1
- package/dist/us-household-adapters.d.ts +1 -1
- package/dist/us-household-adapters.js +1 -1
- package/dist/us-household.cjs +1 -1
- package/dist/us-household.d.ts +1 -1
- package/dist/us-household.js +213 -200
- package/dist/validation.d.ts +16 -0
- package/dist/validation.d.ts.map +1 -0
- package/package.json +13 -2
- package/src/uk-household/adapters/householdImpactRequest.ts +164 -0
- package/src/uk-household/adapters/index.ts +9 -0
- package/src/uk-household/children.ts +23 -0
- package/src/uk-household/codes.ts +67 -0
- package/src/uk-household/defaults.ts +101 -0
- package/src/uk-household/draft.ts +138 -0
- package/src/uk-household/index.ts +75 -0
- package/src/uk-household/serialize.ts +189 -0
- package/src/uk-household/statePension.ts +69 -0
- package/src/uk-household/types.ts +159 -0
- package/src/uk-household/validate.ts +190 -0
- package/src/us-household/adapters/v1Payload.ts +4 -0
- package/src/us-household/draft.ts +1 -0
- package/src/us-household/normalize.ts +3 -0
- package/src/us-household/serialize.ts +6 -0
- package/src/us-household/types.ts +9 -11
- package/src/us-household/validate.ts +15 -0
- package/src/validation.ts +12 -0
|
@@ -202,20 +202,18 @@ export interface USHouseholdDraft {
|
|
|
202
202
|
* differentiates them. Order is significant for UI labels ("Adult 1", etc.).
|
|
203
203
|
*/
|
|
204
204
|
people: USPersonDraft[];
|
|
205
|
+
/**
|
|
206
|
+
* Annual household childcare costs before childcare subsidies, in dollars.
|
|
207
|
+
* The V1 adapter sends this total once as the SPM-unit input
|
|
208
|
+
* `spm_unit_pre_subsidy_childcare_expenses`; the model allocates costs among
|
|
209
|
+
* children and subtracts subsidies. Do not repeat the total for each child.
|
|
210
|
+
* Leave unset when the app does not ask about childcare costs.
|
|
211
|
+
*/
|
|
212
|
+
childcareExpenses?: number;
|
|
205
213
|
/** Year the household is being modeled for. */
|
|
206
214
|
year: number;
|
|
207
215
|
/** App-controlled household-level fields ignored by the shared adapters. */
|
|
208
216
|
extras?: Record<string, unknown>;
|
|
209
217
|
}
|
|
210
218
|
|
|
211
|
-
export
|
|
212
|
-
/** Stable identifier for the rule (e.g. "state.required"). */
|
|
213
|
-
code: string;
|
|
214
|
-
/** Path into the draft (dotted), e.g. "state" or "people[1].age". */
|
|
215
|
-
path: string;
|
|
216
|
-
message: string;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
export type ValidationResult =
|
|
220
|
-
| { ok: true; issues: never[] }
|
|
221
|
-
| { ok: false; issues: ValidationIssue[] };
|
|
219
|
+
export type { ValidationIssue, ValidationResult } from '../validation';
|
|
@@ -47,6 +47,21 @@ export function validate(
|
|
|
47
47
|
const { requireCounty = false, requireAges = true } = options;
|
|
48
48
|
const issues: ValidationIssue[] = [];
|
|
49
49
|
|
|
50
|
+
const childcare = toAmount(draft.childcareExpenses);
|
|
51
|
+
if (draft.childcareExpenses != null && childcare === undefined) {
|
|
52
|
+
issues.push({
|
|
53
|
+
code: 'childcareExpenses.invalid',
|
|
54
|
+
path: 'childcareExpenses',
|
|
55
|
+
message: 'Childcare expenses must be a finite amount.',
|
|
56
|
+
});
|
|
57
|
+
} else if (childcare !== undefined && childcare < 0) {
|
|
58
|
+
issues.push({
|
|
59
|
+
code: 'childcareExpenses.negative',
|
|
60
|
+
path: 'childcareExpenses',
|
|
61
|
+
message: 'Childcare expenses cannot be negative.',
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
if (!draft.state) {
|
|
51
66
|
issues.push({
|
|
52
67
|
code: 'state.required',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** One problem `validate()` found in a draft. Shared by the country models. */
|
|
2
|
+
export interface ValidationIssue {
|
|
3
|
+
/** Stable identifier for the rule (e.g. "state.required"). */
|
|
4
|
+
code: string;
|
|
5
|
+
/** Path into the draft (dotted), e.g. "state" or "people[1].age". */
|
|
6
|
+
path: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type ValidationResult =
|
|
11
|
+
| { ok: true; issues: never[] }
|
|
12
|
+
| { ok: false; issues: ValidationIssue[] };
|