-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Empty string id is not correctly validated by forceId #1519
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Sandbox sources: loopback-sandbox-bug-empty-id-mongodb.zip (repository deleted) |
@simonbrunel thank you for reporting this issue and sorry for responding so late! Originally, I wanted to respond to your comment #1453 (comment) and say that I am not sure if your analysis of
IIUC, I suspect the problem is caused by something else, either in LoopBack implementation or in the configuration of your application. I am afraid I don't have enough time to investigate this myself :( |
@bajtos if (forceId) {
// if id is an empty string, validation passes because blank() returns true
ModelClass.validatesAbsenceOf(idName, {if: 'isNewRecord'});
} |
@simonbrunel oh, you are right, I should not be analyzing code on Friday evening. In this case, I have the following proposal:
@rashmihunt @jannyHou @kjdelisle thoughts? |
Hi, any update on this issue ? I maybe will try to make a PR (if I have time). |
@bajtos Your suggestion #1519 (comment) sounds good to me 👍 @Yaty Thank you! Feel free to open a PR for fix, I can review and help you land it! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Not stale, we have a pull request in progress: #1576 |
Description/Steps to reproduce
forceId: true
{"id": ""}
Seems related to #1453 (see my comment)
Link to reproduction sandbox
https://github.com/simonbrunel/loopback-sandbox/tree/bug/empty-id-mongodb
Expected result
Additional information
The text was updated successfully, but these errors were encountered: