rest-validation

Implements OrangeHRM REST API v2 request validation using ParamRule, Rule, and ValidationDecorator classes.

Updated Jul 23, 2026
Ready to run
npx skills add https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone --skill rest-validation-snow-gift111
💬 Prompt for ChatGPT / Claude Chat▼
Please help me install this Agent Skill.
Skill: rest-validation
Source: https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone/tree/main/.agents/skills/rest-validation
Command: npx skills add https://github.com/snow-gift111/orangehrm-ai-sdlc-capstone --skill rest-validation-snow-gift111

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing input validation for OrangeHRM REST API v2 endpoints requires knowing which rule classes exist, how to combine them, and how required/not-required semantics work — mistakes produce confusing 422 responses or silently-passing empty fields. ## Core Features & Use Cases - Validation rule catalog: Documents the Rules::* constant catalog covering OrangeHRM custom rules (EMAIL, ENTITY_UNIQUE_PROPERTY, IN_ACCESSIBLE_EMP_NUMBERS) and Respect/Validation rules. - Custom rule authoring: Shows how to write new rule classes extending AbstractRule, including DB-backed rules via EntityManagerHelperTrait. - Use Case: When implementing getValidationRuleForCreate() for a new Endpoint and a required field accepts an empty string, use the excludeEmptyString flag on requiredParamRule to reject "" values. ## Quick Start Ask the agent to write the getValidationRuleForCreate method for a new OrangeHRM API endpoint with a required unique name field.

Frequently Asked Questions about rest-validation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write validation rules for an OrangeHRM REST API endpoint?▼

Implement getValidationRuleFor<Verb>() on your Endpoint class returning a ParamRuleCollection with one ParamRule per parameter. Wrap each ParamRule in requiredParamRule or notRequiredParamRule from the ValidationDecorator so absent fields behave correctly.

How do I validate that a field value is unique in the database?▼

Use Rules::ENTITY_UNIQUE_PROPERTY with the entity class and property name. For updates, pass an EntityUniquePropertyOption with setIgnoreValues(['id' => $id]) so the current row is excluded from the uniqueness check.

Why does a required field pass validation when an empty string is sent?▼

The requiredParamRule decorator treats an empty string as present by default. Pass true as the excludeEmptyString argument so empty strings are treated as missing and fail validation.

Why do I get a 422 Unexpected Parameter error in OrangeHRM API?▼

ParamRuleCollection is strict by default, so any request parameter without a matching ParamRule is rejected with a 422. Either add a validation rule for that parameter or remove it from the request.

How do I create a custom validation rule class in OrangeHRM?▼

Extend OrangeHRM\Core\Api\V2\Validator\Rules\AbstractRule and implement validate($input): bool, returning false rather than throwing on mismatch. Register the class as a constant in Rules.php, and use EntityManagerHelperTrait if the rule needs database access.