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

​[UForm] Feature Request: Make deferInputValidation Configurable in useFormField​​ #3810

Open
brin000 opened this issue Apr 6, 2025 · 0 comments
Assignees
Labels
enhancement New feature or request triage v3 #1289

Comments

@brin000
Copy link

brin000 commented Apr 6, 2025

Description

🔧 Current Behavior

The deferInputValidation parameter in useFormField is currently hardcoded in the Input component:

const { emitFormBlur, emitFormInput, /* ... */ } = useFormField<InputProps>(props, { 
  deferInputValidation: false // Hardcoded
})

This limits flexibility, as consumers of the Input component cannot control validation timing behavior (e.g., validate on blur vs. validate on input).

✅ Proposed Solution

Make deferInputValidation configurable via a component prop:

  1. Pass dynamic value to useFormField:
useFormField<InputProps>(props, {
  deferInputValidation: props.deferInputValidation
})
  1. Update the component props interface:
deferInputValidation?: boolean

💡 Use Cases

  • Delayed validation for complex, interdependent form fields
  • Immediate validation for sensitive or critical fields
  • Flexibility for UX patterns like "validate-on-blur" or "validate-as-you-type"

🔁 Alternatives Considered

  • Wrapper Component: Adds unnecessary complexity
  • Global Form-Level Config: Less flexible than per-field control

🧪 Testing Impact

  • Covered by existing validation tests with both true and false cases

📚 Documentation

Requires updates to:

  • Component prop API
  • Form validation best practices

⚙️ Why This Matters

This change supports Inversion of Control — empowering component consumers to control validation timing based on specific UX needs.


### Additional context

_No response_
@brin000 brin000 added enhancement New feature or request triage v3 #1289 labels Apr 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage v3 #1289
Projects
None yet
Development

No branches or pull requests

2 participants