Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Dataset is not passed to context in StopOnError()

Đang mở
#822 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
65/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
backend-api-design

Hướng nghiên cứu

Look at the StopOnError rule implementation to see how it creates a ValidationContext for its nested rules. The dataset should be passed from the outer context. Check the Callback rule usage in the test suite to understand the expected behavior. Verify the fix by running existing validation tests, especially those involving nested Each and StopOnError.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Description

Current scope's dataset is not set in context inside StopOnError():

'property' => [
    new Callback(
        function (mixed $value, Callback $rule, ValidationContext $context): Result {
            $context->getDataSet()->getData(); // <= dataset array
        }
    ),
    new StopOnError([
        new Callback(
            function (mixed $value, Callback $rule, ValidationContext $context): Result {
                $context->getDataSet()->getData(); // <= null (bug)
            }
        ),
    ]),
]

this could be worked around using $context->getGlobalDataSet() and extracting data from there,
but it would be not possible in case if multiple nested Each() used, because in context parameters there is index for the last Each() only

Package version

No response

PHP version

No response

Ngôn ngữ chính
PHP
Star
167
Fork
47
Merge trung bình
1 ngày 16 giờ
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của yiisoft/validator

Tất cả issue của yiisoft/validator

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.