| 9 | imports: [CountrySelector, FormField], |
| 10 | }) |
| 11 | export class App { |
| 12 | // Signal Forms setup |
| 13 | model = signal({country: ''}); |
| 14 | countryForm = form(this.model, (p) => { |
| 15 | required(p.country, {message: 'Country selection is required'}); |
| 16 | |
| 17 | validate(p.country, (ctx) => { |
| 18 | const value = ctx.value(); |
| 19 | if (value && !ALL_COUNTRIES.includes(value)) { |
| 20 | return { |
| 21 | kind: 'invalidCountry', |
| 22 | message: 'Please select a valid country.', |
| 23 | }; |
| 24 | } |
| 25 | return null; |
| 26 | }); |
| 27 | }); |
| 28 | } |