mcpField
L
laravel-validation

laravel-validation

github.com/leeoveryDevelopment1552 installsUpdated 2w ago
Repository

About laravel-validation

A Laravel development skill that organizes form-request validation rules and systematic validation tests. It is for developers building Laravel applications that want requests to define validation behavior and tests to cover it.

Key features

  1. 01Array-based and custom validation rules
  2. 02Conditional rules and custom error messages
  3. 03DTO transformation with `toDto()`
  4. 04Pest datasets for validation tests
  5. 05Nested arrays and field-presence testing

Use cases

  1. 01Define validation in Laravel form requests
  2. 02Test conditional and nested input rules
  3. 03Check fields governed by `present`, `sometimes` or `missing`
  4. 04Transform validated request data into DTOs

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/leeovery/agentic-skills --skill laravel-validation

After installing, type/laravel-validationin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
form-requests.md
macro-setup.md
MacroServiceProvider.php
RequestDataProviderItem.php
validation-testing.md
ValidPostcodeRule.php

Details

From the project README

Laravel Validation

Form requests as single source of truth for validation, with comprehensive testing patterns.

Core Concepts

form-requests.md - Validation rules:

  • Array-based validation rules
  • Custom validation rules
  • Conditional validation
  • Custom error messages
  • DTO transformation via toDto()

validation-testing.md - Validation testing:

  • RequestDataProviderItem helper
  • Pest datasets for systematic testing
  • Built-in helper methods (string, email, number, date, array, boolean)
  • Presence testing with absent() (for present / sometimes / missing rules)
  • Nested array testing
  • Conditional validation testing
  • Real-world examples

Pattern

final class CreateOrderRequest extends FormRequest
{
    public function rules(): array
    {
        return [
            'user_id' => ['required', 'integer', 'exists:users,id'],
            'items' => ['required', 'array', 'min:1'],
            'items.*.product_id' => ['required', 'integer'],
            'items.*.quantity' => ['required', 'integer', 'min:1'],
        ];
    }

    public function toDto(): CreateOrderDto
    {
        return CreateOrderDto::from($this->validated());
    }
}

All validation lives in form requests. Test validation systematically.

Comments

Markdown supported