diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 0000000..788bb46
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,37 @@
+{
+ "arrowParens": "always",
+ "bracketSpacing": true,
+ "endOfLine": "lf",
+ "htmlWhitespaceSensitivity": "css",
+ "insertPragma": false,
+ "singleAttributePerLine": false,
+ "bracketSameLine": false,
+ "jsxBracketSameLine": false,
+ "jsxSingleQuote": true,
+ "printWidth": 120,
+ "proseWrap": "preserve",
+ "quoteProps": "as-needed",
+ "requirePragma": false,
+ "semi": false,
+ "singleQuote": true,
+ "tabWidth": 2,
+ "trailingComma": "es5",
+ "useTabs": false,
+ "embeddedLanguageFormatting": "auto",
+ "vueIndentScriptAndStyle": false,
+ "experimentalTernaries": false,
+ "overrides": [
+ {
+ "files": "*.ts",
+ "options": {
+ "parser": "typescript"
+ }
+ },
+ {
+ "files": "*.vue",
+ "options": {
+ "parser": "vue"
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/src/islands/FormField.vue b/src/islands/FormField.vue
new file mode 100644
index 0000000..3dd5fb7
--- /dev/null
+++ b/src/islands/FormField.vue
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
diff --git a/src/islands/LoginForm.vue b/src/islands/LoginForm.vue
index a883257..1acc119 100644
--- a/src/islands/LoginForm.vue
+++ b/src/islands/LoginForm.vue
@@ -1,56 +1,41 @@
-
diff --git a/src/pages/sign-in.astro b/src/pages/sign-in.astro
index d5a748b..f8b69a5 100644
--- a/src/pages/sign-in.astro
+++ b/src/pages/sign-in.astro
@@ -1,23 +1,32 @@
---
-import Layout from "../layouts/layout.astro";
-import LoginForm from "../islands/LoginForm.vue";
+import LoginForm from '../islands/LoginForm.vue'
+import Layout from '../layouts/layout.astro'
+import { loginSchema } from '../schemas/login'
-let email = "";
-let error = "";
+let email = ''
+let error = ''
-if (Astro.request.method === "POST") {
- const formData = await Astro.request.formData();
+if (Astro.request.method === 'POST') {
+ const formData = await Astro.request.formData()
+ const input = {
+ email: formData.get('email'),
+ password: formData.get('password'),
+ }
+ const result = loginSchema.safeParse(input)
- email = formData.get("email")?.toString() ?? "";
+ email = typeof input.email === 'string' ? input.email : ''
- if (!email) {
- error = "E-Mail shouldn't be empty.";
+ if (!result.success) {
+ error = result.error.issues[0]?.message ?? 'Invalid form data.'
+ } else {
+ email = result.data.email
+ console.log('POST DATA', result.data)
}
}
---
- Sign in
+ Sign in
-
+
diff --git a/src/schemas/login.ts b/src/schemas/login.ts
new file mode 100644
index 0000000..4d540db
--- /dev/null
+++ b/src/schemas/login.ts
@@ -0,0 +1,8 @@
+import z from 'zod'
+
+export const loginSchema = z.object({
+ email: z.string().trim().pipe(z.email()),
+ password: z.string().min(8),
+})
+
+export type LoginForm = z.infer