You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/tutorial/02-sveltekit/04-forms/03-form-validation/README.md
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,9 @@
2
2
title: Validation
3
3
---
4
4
5
-
Users are a mischievous bunch, who will submit all kinds of nonsensical data if given the chance. To prevent them from causing chaos, it's important to validate form data.
The first line of defense is the browser's [built-in form validation](https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation#using_built-in_form_validation), which makes it easy to, for example, mark an `<input>`as required:
7
+
第一防衛ラインは、ブラウザに[組み込まれたフォームバリデーション(built-in form validation)](https://developer.mozilla.org/ja/docs/Learn/Forms/Form_validation#%E7%B5%84%E3%81%BF%E8%BE%BC%E3%81%BF%E3%83%95%E3%82%A9%E3%83%BC%E3%83%A0%E6%A4%9C%E8%A8%BC%E3%81%AE%E5%88%A9%E7%94%A8)で、これによって、例えば `<input>`を必須項目としてマークすることが簡単に行えます。
8
8
9
9
```svelte
10
10
<form method="POST" action="?/create">
@@ -18,11 +18,11 @@ The first line of defense is the browser's [built-in form validation](https://de
18
18
</form>
19
19
```
20
20
21
-
Try hitting Enter while the `<input>`is empty.
21
+
`<input>`を空にしたまま Enter を押してみてください。
22
22
23
-
This kind of validation is helpful, but insufficient. Some validation rules (e.g. uniqueness) can't be expressed using `<input>`attributes, and in any case, if the user is an elite hacker they might simply delete the attributes using the browser's devtools. To guard against these sorts of shenanigans, you should always use server-side validation.
@@ -49,9 +49,9 @@ export function createTodo(userid, description) {
49
49
}
50
50
```
51
51
52
-
Try submitting a duplicate todo. Yikes! SvelteKit takes us to an unfriendly-looking error page. On the server, we see a 'todos must be unique' error, but SvelteKit hides unexpected error messages from users because they often contain sensitive data.
52
+
重複した todo を送信してみてください。おっと! SvelteKit は不親切なエラーページを表示していますね。サーバーでは 'todos must be unique' エラーを見ることができますが、予期せぬエラーメッセージには機密情報が含まれる可能性があるため、SvelteKit ではそれをユーザーには隠しています。
53
53
54
-
It would be much better to stay on the same page and provide an indication of what went wrong so that the user can fix it. To do this, we can use the `fail`function to return data from the action along with an appropriate HTTP status code:
@@ -101,4 +101,4 @@ In `src/routes/+page.svelte`, we can access the returned value via the `form` pr
101
101
</form>
102
102
```
103
103
104
-
> You can also return data from an action _without_ wrapping it in `fail`— for example to show a 'success!' message when data was saved — and it will be available via the `form`prop.
0 commit comments