Is there a way to set specific error messages on validation rules? [duplicate]

送分小仙女□ 提交于 2020-01-05 03:23:26

问题


Let's say that I have a validation rule like "validate": "condition1 && condition2" and I want to show the user an error message according to the first condition that is not met.

For example, if condition1 isn't met, the user would receive a custom message saying that "Condition1 is not met".

Basically, I want to map an error code (or message) to each condition and that should be sent to the user (instead of the classic "Permission denied" message from Firebase).


回答1:


There's not a way to do this. What you could do instead is use Cloud Functions HTTP triggers as an API for writing data. It could check the conditions you want, then return a response that indicates what's wrong with the data the client is trying to write. I understand this is far from ideal, but it might be the best option you have right now.

You can also file a feature request with a description of what you're trying to do.



来源:https://stackoverflow.com/questions/49310892/is-there-a-way-to-set-specific-error-messages-on-validation-rules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!