bitrix-validation

Validate Bitrix DTOs and controllers using PHP 8 attributes and ValidationService.

33|3|Updated Jun 5, 2025
One-click install
npx skills add https://github.com/bxmaximum/bitrix_ai_challenge --skill bitrix-validation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bitrix-validation
Source: https://github.com/bxmaximum/bitrix_ai_challenge/tree/main/.agents/skills/bitrix-validation
Command: npx skills add https://github.com/bxmaximum/bitrix_ai_challenge --skill bitrix-validation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Валидатор входных данных в Bitrix реализован через ValidationService и атрибуты PHP 8 (#[NotEmpty], #[Email], #[Length], #[Range] и др.), что позволяет централизованно валидировать DTO и объекты бизнес-логики, собирая ошибки в ErrorCollection.

Core Features & Use Cases

  • Поддержка атрибутов первого уровня: NotEmpty, Length, Min/Max/Range, Email, Phone, Url, RegExp, Json, Validatable, ElementsType и AtLeastOnePropertyNotEmpty.
  • Валидаторы для DTO и сервисов: использование Bitrix\Main\Validation\ValidationService для валидации объектов и генерации результатов с ошибками.
  • Интеграция с контроллерами через #[ValidationParameter] и автоматическая генерация DTO из GET/POST с последующей валидацией.

Quick Start

Создайте DTO с атрибутами валидации и вызовите ValidationService для проверки.

Применение и примеры

Справка описывает примеры DTO и соответствующих правил, а также настройку кастомных валидаторов и регистров правил.

Frequently Asked Questions about bitrix-validation

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

FAQPage Schema
How do I validate input data in a Bitrix application using PHP 8 attributes?

You can validate input data in Bitrix by defining DTOs with PHP 8 attributes like NotEmpty, Email, Length, and Range, then using Bitrix\Validation\ValidationService to process them and return a ValidationResult with any errors.

Can I automatically validate controller parameters in Bitrix?

Yes, Bitrix controller integration supports automatic generation of DTOs from GET and POST requests, followed by validation using the #[ValidationParameter] attribute to ensure input integrity before processing.

What built-in validation rules are available for Bitrix DTOs?

Available validation rules for Bitrix DTOs include first-level attributes such as NotEmpty, Length, Min, Max, Range, Email, Phone, Url, RegExp, Json, Validatable, ElementsType, and AtLeastOnePropertyNotEmpty.

Does Bitrix validation support custom rules and service-level validation?

Yes, the Bitrix ValidationService allows you to validate service and business logic objects, configure custom validators, and register custom rules to collect errors within an ErrorCollection.

What is the best way to collect validation errors from multiple Bitrix DTO fields?

The ValidationService processes Bitrix DTOs and aggregates all field-level attribute failures into a single ValidationResult object, utilizing an ErrorCollection to centralize validation errors for review.

Do I need PHP 8 to use attribute-based validation in Bitrix?

Yes, attribute-based validation in Bitrix requires PHP 8 to utilize native attributes like #[NotEmpty] and #[Email] for rule definitions and to run the Bitrix ValidationService effectively.