web-player: share form limits between client and server and extract form parsers
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
import Field from '../primitives/Field.svelte';
|
||||
import Input from '../primitives/Input.svelte';
|
||||
import Textarea from '../primitives/Textarea.svelte';
|
||||
import { ALBUM_EARLIEST_YEAR } from '$lib/config';
|
||||
import { ALBUM_EARLIEST_YEAR, LIMITS } from '$lib/validation';
|
||||
|
||||
interface Props {
|
||||
action: string;
|
||||
@@ -58,10 +58,13 @@
|
||||
>
|
||||
{#snippet fields()}
|
||||
<Field label="Título" for="album-title">
|
||||
{#snippet hint()}
|
||||
<span class="ml-auto tabular-nums">{title.length}/{LIMITS.albumTitle}</span>
|
||||
{/snippet}
|
||||
<Input
|
||||
id="album-title"
|
||||
name="title"
|
||||
maxlength={200}
|
||||
maxlength={LIMITS.albumTitle}
|
||||
required
|
||||
bind:value={title}
|
||||
placeholder={titlePlaceholder}
|
||||
@@ -85,7 +88,7 @@
|
||||
<Textarea
|
||||
id="album-description"
|
||||
name="description"
|
||||
maxlength={256}
|
||||
maxlength={LIMITS.albumDescription}
|
||||
bind:value={description}
|
||||
placeholder="¿De qué va este álbum?"
|
||||
/>
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
import Textarea from '../primitives/Textarea.svelte';
|
||||
import SegmentedControl from '../primitives/SegmentedControl.svelte';
|
||||
|
||||
const NAME_MAX_LENGTH = 60;
|
||||
const DESCRIPTION_MAX_LENGTH = 300;
|
||||
import { LIMITS } from '$lib/validation';
|
||||
|
||||
interface Props {
|
||||
action: string;
|
||||
@@ -61,12 +60,12 @@
|
||||
<input type="hidden" name="visibility" value={visibility} />
|
||||
<Field label="Nombre" for="playlist-name">
|
||||
{#snippet hint()}
|
||||
<span class="ml-auto tabular-nums">{name.length}/{NAME_MAX_LENGTH}</span>
|
||||
<span class="ml-auto tabular-nums">{name.length}/{LIMITS.playlistName}</span>
|
||||
{/snippet}
|
||||
<Input
|
||||
id="playlist-name"
|
||||
name="name"
|
||||
maxlength={NAME_MAX_LENGTH}
|
||||
maxlength={LIMITS.playlistName}
|
||||
required
|
||||
bind:value={name}
|
||||
placeholder={namePlaceholder}
|
||||
@@ -77,7 +76,7 @@
|
||||
<Textarea
|
||||
id="playlist-description"
|
||||
name="description"
|
||||
maxlength={DESCRIPTION_MAX_LENGTH}
|
||||
maxlength={LIMITS.playlistDescription}
|
||||
bind:value={description}
|
||||
placeholder="Para qué sirve esta playlist, cuándo la escuchas…"
|
||||
class="flex-1"
|
||||
|
||||
Reference in New Issue
Block a user