Skip to content

Commit b3e64ac

Browse files
committed
translate 02-sveltekit/04-forms/03-form-validation into Japanese
1 parent bca50af commit b3e64ac

File tree

1 file changed

+9
-9
lines changed
  • content/tutorial/02-sveltekit/04-forms/03-form-validation

1 file changed

+9
-9
lines changed

content/tutorial/02-sveltekit/04-forms/03-form-validation/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
title: Validation
33
---
44

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.
5+
ユーザーはいたずら好きな集団であり、隙あらばあらゆる種類の無意味なデータを送信しようとします。彼らが混乱を引き起こすのを防ぐには、フォームデータを検証することが重要です。
66

7-
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>` を必須項目としてマークすることが簡単に行えます。
88

99
```svelte
1010
<form method="POST" action="?/create">
@@ -18,11 +18,11 @@ The first line of defense is the browser's [built-in form validation](https://de
1818
</form>
1919
```
2020

21-
Try hitting Enter while the `<input>` is empty.
21+
`<input>` を空にしたまま Enter を押してみてください。
2222

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.
23+
この種類のバリデーションは役に立ちますが、十分ではありません。`<input>` の属性では表現できないバリデーションルール (例えば一意性) もありますし、いずれの場合においても、ユーザーがエリートハッカーなら、ブラウザのデベロッパーツールを使用して属性を削除してしまうかもしれません。このようないたずらから防御するには、常にサーバーサイドのバリデーションを使用する必要があります。
2424

25-
In `src/lib/server/database.js`, validate that the description exists and is unique:
25+
`src/lib/server/database.js` で、description が存在すること、そして一意であることをバリデートします。
2626

2727
```js
2828
/// file: src/lib/server/database.js
@@ -49,9 +49,9 @@ export function createTodo(userid, description) {
4949
}
5050
```
5151

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 ではそれをユーザーには隠しています。
5353

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:
54+
同じページを表示させたまま何が問題だったのかを示し、ユーザーがそれを修正できるようにするほうが良いでしょう。これを行うために、`fail` 関数を使用して、action からデータと適切な HTTP ステータスコードを返すことができます。
5555

5656
```js
5757
/// file: src/routes/+page.server.js
@@ -74,7 +74,7 @@ export const actions = {
7474
}
7575
```
7676
77-
In `src/routes/+page.svelte`, we can access the returned value via the `form` prop, which is only ever populated after a form submission:
77+
`src/routes/+page.svelte` では、`form` プロパティを介してその戻り値にアクセスすることができます。このプロパティはフォーム送信の後にのみ、値が入っています。
7878
7979
```svelte
8080
/// file: src/routes/+page.svelte
@@ -101,4 +101,4 @@ In `src/routes/+page.svelte`, we can access the returned value via the `form` pr
101101
</form>
102102
```
103103
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.
104+
> `fail` でラップしなくても、action から値を返すことができます。例えば、データが保存されたときに 'success!' というメッセージを返すこともできます。それも `form` プロパティを介してアクセスすることができます。

0 commit comments

Comments
 (0)