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

Direct validation in user controllers instead of Form Requests #632

Open
idehen-divine opened this issue Feb 28, 2025 · 0 comments
Open

Comments

@idehen-divine
Copy link

Title: Direct Validation in Controllers Instead of Form Requests

Issue Description

Currently, validation is being done directly inside controller methods using $request->validate([...]). This approach can make controllers bulky and harder to maintain. Instead, we should use Form Request classes to separate validation logic, improve reusability, and keep controllers clean.

Problems with Current Approach

  • Controllers contain validation logic, making them harder to read and maintain.
  • Validation rules are not reusable across multiple methods.
  • No centralized place to handle custom validation messages or logic.

Proposed Solution

  • Move validation logic to dedicated Form Request classes.
  • Update controllers to use $request->validated() instead of handling validation directly.
  • Ensure all validation rules remain unchanged.

Benefits of This Change

✅ Keeps controllers clean and focused on business logic.
✅ Reusable validation rules across multiple methods.
✅ Easier to maintain and modify validation rules in one place.
✅ Allows better handling of custom validation messages.

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

No branches or pull requests

1 participant