Skip to content

Commit

Permalink
feat: improve form validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Marchois committed Jul 16, 2021
1 parent 3b6dad8 commit cec5660
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('CreateEventCommandHandler', () => {
).thenResolve(null);

try {
await handler.execute(command);
expect(await handler.execute(command)).toBeUndefined();
} catch (e) {
expect(e).toBeInstanceOf(UserNotFoundException);
expect(e.message).toBe('users.errors.not_found');
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/inputs/Input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<div class={`block text-sm ${marginClass}`}>
{#if label}
<label class="text-gray-700 dark:text-gray-400" for={id}>{label}</label>
<label class="text-gray-700 dark:text-gray-400 {required}" for={id}>{label}</label>
{/if}
{#if type === 'email'}
<input
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/inputs/SelectInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</script>

<div class="block mb-4 text-sm">
<label class="text-gray-700 dark:text-gray-400" for="{id}">{label}</label>
<label class="text-gray-700 dark:text-gray-400 {required}" for="{id}">{label}</label>
<select
{id}
{required}
Expand Down
3 changes: 1 addition & 2 deletions client/src/routes/admin/schools/_Form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
<Input
label={$_('schools.form.email')}
type={'email'}
required={false}
bind:value={email} />
<Input
label={$_('schools.form.phone_number')}
Expand All @@ -99,5 +98,5 @@
<Button
value={$_('common.form.save')}
loading={loading}
disabled={!reference || !name || !address || !city || !zipCode || !status || !type || loading} />
disabled={!reference || !name || !address || !city || !email || !zipCode || !status || !type || loading} />
</form>
5 changes: 5 additions & 0 deletions client/static/css/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@
background: #fff;
display: block;
}

label.required:after {
content: ' *';
color: #e32;
}

0 comments on commit cec5660

Please sign in to comment.