wpdiggerstudio/wpzylos-validation

Minimal validation with localized messages for WPZylos framework

Fund package maintenance!
Paypal

Installs: 234

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/wpdiggerstudio/wpzylos-validation

v1.0.0 2026-02-01 13:02 UTC

This package is auto-updated.

Last update: 2026-02-01 13:03:54 UTC


README

PHP Version License GitHub

Minimal validation with localized messages for WPZylos framework.

📖 Full Documentation | 🐛 Report Issues

✨ Features

  • Validation Rules — Required, email, min, max, and more
  • Custom Rules — Create your own validation rules
  • Localized Messages — Translatable error messages
  • FormRequest — Laravel-style form validation
  • Array Validation — Validate nested data

📋 Requirements

Requirement Version
PHP ^8.0

🚀 Installation

composer require wpdiggerstudio/wpzylos-validation

📖 Quick Start

use WPZylos\Framework\Validation\Validator;

$validator = new Validator($data, [
    'name' => ['required', 'string', 'max:255'],
    'email' => ['required', 'email'],
    'age' => ['required', 'integer', 'min:18'],
]);

if ($validator->fails()) {
    $errors = $validator->errors();
}

🏗️ Core Features

Available Rules

$rules = [
    'name' => ['required', 'string', 'min:2', 'max:100'],
    'email' => ['required', 'email'],
    'age' => ['required', 'integer', 'min:18', 'max:120'],
    'website' => ['nullable', 'url'],
    'password' => ['required', 'min:8', 'confirmed'],
    'terms' => ['accepted'],
    'category' => ['required', 'in:tech,news,sports'],
];

Custom Rules

Validator::extend('phone', function ($attribute, $value) {
    return preg_match('/^\+?[1-9]\d{1,14}$/', $value);
}, 'The :attribute must be a valid phone number.');

// Usage
$rules = ['phone' => ['required', 'phone']];

Error Messages

if ($validator->fails()) {
    foreach ($validator->errors()->all() as $error) {
        echo $error;
    }

    // Get errors for a specific field
    $emailErrors = $validator->errors()->get('email');
}

Custom Error Messages

$validator = new Validator($data, $rules, [
    'email.required' => 'We need your email address.',
    'email.email' => 'Please enter a valid email.',
]);

📦 Related Packages

Package Description
wpzylos-core Application foundation
wpzylos-http HTTP handling
wpzylos-scaffold Plugin template

📖 Documentation

For comprehensive documentation, tutorials, and API reference, visit wpzylos.com.

☕ Support the Project

If you find this package helpful, consider buying me a coffee! Your support helps maintain and improve the WPZylos ecosystem.

Donate with PayPal

📄 License

MIT License. See LICENSE for details.

🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

Made with ❤️ by WPDiggerStudio