1602 / 1602/jugglingdb

It is impossible to use this.errors.add(attr, message) in a Model Callback

Đang mở
#219 9 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
2k
Fork
238
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

for example for "beforeCreate" callback you should invoke "this.isValid()" to make
" this.errors.add(attr, message)" works as expected(but it works if you have at least one model validation).

The main reason of such error is validatable.js.
in the "isValid" method it set correct initial value for errors:

Object.defineProperty(this, 'errors', {
enumerable: false,
configurable: true,
value: new Errors
});

But in the "cleanErrors" method it set boolean value instead of "new Error":

```
Object.defineProperty(inst, 'errors', {
enumerable: false,
configurable: true,
value: false
});
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Look at the validatable.js file, specifically the 'isValid' and 'cleanErrors' methods. The bug is that 'cleanErrors' sets errors to a boolean instead of a new Errors instance. Start by understanding the model callback flow (like beforeCreate) and how errors are managed. Write a test to reproduce the issue where this.errors.add fails in a callback without prior validation. Check if there are existing tests for model validation or callbacks to see the expected behavior.

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

Đánh giá

Công nghệ
javascript, nodejs
Lĩnh vực
backend, databases
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

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.