Meteor-Community-Packages / meteor-collection2

A Meteor package that extends Mongo.Collection to provide support for specifying a schema and then validating against that schema when inserting and updating.
https://packosphere.com/aldeed/collection2
MIT License
1.02k stars 108 forks source link

Delete the name of collections in error messages #422

Closed Saeeed-B closed 3 years ago

Saeeed-B commented 3 years ago

When errors are returned (If the input information is incorrect) , The name of the corresponding collection is also in the error message . LIKE this :

name is required in CollectionName insert

i want this part (in CollectionName insert ) gone.

error messages belong to software users, and users do not need to see the name of the collection. And this part should not be returned at all.

And this is about this line:

https://github.com/Meteor-Community-Packages/meteor-collection2/blob/master/package/collection2/collection2.js#L479

I also raised this issue in the simpl-schema, but it is not related to simpl-schema.

For more details, please refer to the following links:

https://github.com/aldeed/simpl-schema/issues/408

https://forums.meteor.com/t/delete-the-name-of-collections-in-error-messages-in-simpl-schema/54073/18

StorytellerCZ commented 3 years ago

Probably good to leave for development and get rid of it in production.

copleykj commented 3 years ago

I'm not sure this is an issue.. These error messages should never be seen by the user. Errors should be caught, handled in application code, and custom error messages propagated to the UI.

StorytellerCZ commented 3 years ago

That might be so, but with Meteor it is easy to do error.message in method callback and just return that, so it is probably too common (I'm guilty of this as well). But if your error handling depends on string parsing with the collection name then this would be a breaking change...

Saeeed-B commented 3 years ago

@copleykj @StorytellerCZ This is exactly the problem, we can easily show the exact error to the user, and more importantly, this error is in any language we want. And when we show these messages to the user, there is no need for many additional validations. Please look at the error system in Laravel, they take the user field and if it does not match any of the credentials, they show the message corresponding to the same credential. If we can make the validation only in the collection is great, because it no longer matters where the input comes from, in any case it must have the necessary validity. Also, if it is not valid, a very accurate message will be displayed. I hope I was able to get it right, because I do not speak English very well

StorytellerCZ commented 3 years ago

I think the compromise might be that on production the collection name will be hidden while we leave it as is for development.