Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

フロントエンドの入力フォームのバリデーションを改善する #1643

Open
3 tasks
KentaHizume opened this issue Aug 27, 2024 · 4 comments
Open
3 tasks
Labels
target: Azure AD B2C Auth Azure AD B2C認証の要件別サンプルに関係がある target: Dressca サンプルアプリケーションDresscaに関係がある
Milestone

Comments

@KentaHizume
Copy link
Contributor

KentaHizume commented Aug 27, 2024

概要

フロントエンドの入力フォームのバリデーションを改善する。
実装方針、実装例のバリエーション、ドキュメントについて不足している点を改善する。

詳細 / 機能詳細(オプション)

現在は、Dressca Consumerのログイン画面にのみ実装されており、
パターンは文字列、メールアドレス、必須の3つのみ。

const formSchema = yup.object({
  email: validationItems.email.required(),
  password: yup.string().required(),
});

image

方針

validation-items.tsで定義しているものと、各ViewModelで定義しているものがあるので、使い分けの指針が必要。
画面を開いた初期状態ではバリデーションメッセージが出ないが、出たほうがよいか?
メッセージはyup.config.tsで定義しているが、多言語対応を考えたときにここでよいか?

実装

買い物かご画面のアイテムの数量について、バリデーションが行われていないので実装をする。
ログイン画面のパスワードについて、必須チェックのみなのでパターンのチェックの実装をする。

ドキュメント

https://maris.alesinfiny.org/guidebooks/how-to-develop/vue-js/input-validation/#input-validation

入力値検証の実行について、公式ドキュメントへの参照のみで具体的な記述が不足しているので、追記したい。

完了条件

  • 入力フォームのバリデーションが改善されていること
  • 入力フォームにバリデーションが実装されていること
  • ドキュメントが更新されていること
@KentaHizume KentaHizume added this to the v1.0 milestone Aug 27, 2024
@KentaHizume
Copy link
Contributor Author

KentaHizume commented Aug 27, 2024

Adminではカタログアイテムの名称、説明、単価、商品コードについて下記のようなバリデーションの実装を行っている。

https://vee-validate.logaretm.com/v4/guide/composition-api/typed-schema/

export const catalogItemSchema: TypedSchema = toTypedSchema(
  yup.object({
    name: yup
      .string()
      .required('アイテム名は必須です。')
      .max(256, '256文字以下で入力してください。'),
    description: yup
      .string()
      .required('説明は必須です。')
      .max(1024, '1024文字以下で入力してください。'),
    price: yup
      .number()
      .required('単価は必須です。')
      .typeError('数値で入力してください。')
      .integer('整数で入力してください。')
      .positive('正の数で入力してください。'),
    productCode: yup
      .string()
      .required('商品コードは必須です。')
      .max(128, '128文字以下で入力してください。')
      .matches(/^[0-9a-zA-Z]+$/, '半角英数字で入力してください。'),
  }),
);

@KentaHizume
Copy link
Contributor Author

他のinput要素だと買い物かごの数量があるが、
input要素にtype="number"が指定されているので半角数字以外は入力できないようになっている。

image

@KentaHizume KentaHizume changed the title フロントエンドの入力フォームにバリデーションを実装する フロントエンドの入力フォームnoバリデーションを実装する Aug 27, 2024
@KentaHizume KentaHizume changed the title フロントエンドの入力フォームnoバリデーションを実装する フロントエンドの入力フォームのバリデーションを改善する Aug 27, 2024
@KentaHizume
Copy link
Contributor Author

@tsuna-can-se tsuna-can-se added target: Dressca サンプルアプリケーションDresscaに関係がある target: Azure AD B2C Auth Azure AD B2C認証の要件別サンプルに関係がある and removed サンプルAP labels Oct 29, 2024
@tsuna-can-se tsuna-can-se modified the milestones: v1.0.0, v1.1.0 Nov 14, 2024
@KentaHizume
Copy link
Contributor Author

Adminのサンプルだと、TypedSchemaのフィールドの名称を変更した場合にlintや型チェックで修正箇所が特定できないのでもっとよい実装方法があれば修正したい。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
target: Azure AD B2C Auth Azure AD B2C認証の要件別サンプルに関係がある target: Dressca サンプルアプリケーションDresscaに関係がある
Projects
None yet
Development

No branches or pull requests

2 participants