It is impossible to use this.errors.add(attr, message) in a Model Callback
- Lingua principale
- JavaScript
- Stelle
- 2k
- Fork
- 238
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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
});
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, nodejs
- Ambito
- backend, databases
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100