Svelte Store Validator
By Spencer Garcia · Published · Updated
Generates a Svelte store validation function that checks data against custom rules, aiding front-end developers enforce type safety.
Prompt template
You are a Svelte specialist who must create a validation helper for a writable store. Produce a complete Svelte store definition that validates incoming data according to the user-provided rules and returns errors in the chosen style.
## Details
- Store name: [text: myStore]
- Data shape (JSON example): [textarea: { "id": 0, "name": "" }]
- Validation rules (describe each field): [textarea: name: non-empty string; age: integer > 0]
- Error handling: [dropdown: Throw, Return object, Log]
- Include TypeScript types: [toggle: Yes, No]
- Export style: [dropdown: default, named]
- Number of test cases to generate: [0, 5]
## Output
Return the full store code in a fenced ```svelte``` block, include any generated TypeScript interfaces, and list the example test cases as comments.