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

feat: enhance useFormValidator for flexible field-level control and external state injection #5033

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

WANZARGEN
Copy link
Member

@WANZARGEN WANZARGEN commented Nov 15, 2024

To Reviewers

  • Self-reviewed (coding conventions, bug-free, functionality verified, tests checked, documentation updated)
  • Minor change, review optional (style, chore, ci, straightforward changes, etc.)
  • Previously reviewed in feature branch, no further review needed
  • Need review or discussion

Description (optional)

Enhance useFormValidator for Flexible Validation and External State Control

Summary

This PR improves useFormValidator by allowing external injection of both the reactive state and validation �scenario, providing greater flexibility in form validation scenario. Previously, useFormValidator created its own reactive object internally and managed validation as a single unit, which limited adaptability when specific form fields required unique validation behavior. By enabling external state injection and accepting useFieldValidator directly for individual fields, useFormValidator now supports custom validation scenarios within a single form setup without the need for redundant instances.

Major Changes

  • External Reactive State Injection: Enabled the injection of a reactive state object from outside the composable, allowing shared or customized state management across multiple fields or forms.
  • Flexible Validator Handling: Updated the validator option to accept useFieldValidator instances directly for specific fields, supporting unique validation logic and enabling field-level customization within a single form.

Minor Changes

  • Setter Functions Added: Introduced setters to allow updates on readonly refs, providing better external control over validation state adjustments.
  • TypeScript Annotations Improved: Updated and enhanced TypeScript annotations to improve code clarity, maintainability, and type safety across various data structures and validation implementations.

useFormValidator의 유연한 검증 및 외부 상태 제어 기능 향상

요약

이 PR은 useFormValidator에 외부에서 reactive 상태와 validation을 주입할 수 있는 기능을 추가하여 폼 validation의 유연성을 높입니다. 기존에는 useFormValidator가 내부적으로 reactive 객체를 생성하고 validation을 단일 유닛으로 관리했기 때문에 특정 필드에 고유한 validation 동작이 필요한 경우 적응성이 제한되었습니다. 이제 외부에서 상태를 주입하고, 개별 필드를 위해 useFieldValidator를 직접 받아들일 수 있어, 별도의 인스턴스가 필요하지 않으면서 단일 폼 내에서 맞춤형 validation을 지원합니다.

주요 변경 사항

  • 외부 Reactive 상태 주입: composable 외부에서 reactive 상태 객체를 주입할 수 있도록 하여, 여러 필드나 폼에 걸쳐 상태를 공유하거나 맞춤형 상태 관리를 가능하게 했습니다.
  • 유연한 Validator 처리: validator 옵션이 특정 필드를 위해 useFieldValidator 인스턴스를 직접 허용하도록 수정되어, 필드 단위의 고유한 validation을 지원하고 단일 폼 내에서 필드 수준의 커스터마이징을 가능하게 했습니다.

부가 변경 사항

  • Setter 함수 추가: readonly ref의 업데이트를 허용하는 setter 함수를 도입하여 외부에서 validation 상태를 조정할 수 있는 제어권을 강화했습니다.
  • TypeScript 주석 개선: 다양한 데이터 구조와 validation 구현에 대해 코드 가독성, 유지보수성, 타입 안정성을 높이기 위해 TypeScript 주석을 업데이트하고 개선했습니다.

Things to Talk About (optional)

@WANZARGEN WANZARGEN changed the title feat: update useFormValidator to accept reactive object feat: enhance useFormValidator for flexible field-level control and external state injection Nov 15, 2024
Copy link
Member

@skdud4659 skdud4659 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!🌟

Copy link
Member

@piggggggggy piggggggggy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, But why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants