diff --git a/src/Form.svelte b/src/Form.svelte
index 57aae97ed..4938fc9f0 100644
--- a/src/Form.svelte
+++ b/src/Form.svelte
@@ -3,11 +3,28 @@
name: string;
value: string | null;
label?: string;
+ validate?: string;
placeholder?: string;
description: string;
resolve?: boolean;
editable: boolean;
+ error?: string;
}
+
+ const validationTypes: { [index: string]: RegExp } = {
+ url: /^(https:\/\/|http:\/\/|ipfs:\/\/)\S+/,
+ // Github
+ // Username may only contain alphanumeric characters or hyphens.
+ // Username cannot have multiple consecutive hyphens.
+ // Username cannot begin or end with a hyphen.
+ // Maximum is 39 characters.
+ // Twitter
+ // Username may only contain alphanumeric characters or underscores.
+ // Maximum is 15 characters.
+ // For simplification of the regex pattern we use a combined version of both requirements.
+ handle: /^[a-zA-Z0-9-_]{1,39}$/,
+ address: /^0x[a-zA-Z0-9]{40}$/
+ };
- {#each fields as field}
+ {#each formFields as field}
{field.label || capitalize(field.name)}
{#if field.editable && editable}
+ on:keyup={validate} value={field.value} type="text" {disabled} />
{:else}
{#if field.value}
@@ -126,9 +169,15 @@
{/if}
{/if}
-
- {@html marked(field.description)}
-
+ {#if field.error}
+
+ {field.error}
+
+ {:else}
+
+ {@html marked(field.description)}
+
+ {/if}
{/each}
@@ -137,7 +186,7 @@
-