-
Notifications
You must be signed in to change notification settings - Fork 89
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
Internationalize validateSchema messages #242
Comments
Hum... What if common hook integrates ajv-error ? |
In my opinion, add an optional parameter in validateSchema() to pass personalized messages it's the better way |
ajv has its own i18n mechanism. I suggest it would be a bad design for validateSchema to implement its own. |
@eddyystop But I can not find a way to configure it with a before hook, have you an idea ? |
In fact, I just want to hide pattern error throw by Ajv, if it is more
simple to do
Le lun. 7 août 2017 à 01:54, Eddyystop <[email protected]> a écrit :
… ajv has its own i18n mechanism. I suggest it would be a bad design for
validateSchema to implement its own.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#242 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AYPoIaRte_-1wXY3eT65a03qEiS3NBTDks5sVlJAgaJpZM4Ouuti>
.
|
You can achomplish either internationalisation or changing error message the documented addNewError option. Copy the default function in the hook, customize it to your needs, and pass it to validateSchema. https://docs.feathersjs.com/api/hooks-common.html#validateschema addNewError (optional) - Custom message formatter. Its a reducing function which works similarly to Array.reduce(). Its signature is currentFormattedMessages - Formatted messages so far. Initially null. |
Sound good ! Could you add an example in the doc, or just here. (I must admit, ajv seems a little complicated) ? In any case, thank you for your work ! 😄 |
Make a copy of this https://github.com/feathersjs/feathers-hooks-common/blob/master/src/services/validate-schema.js#L65-L79 including some Pass that along as Make changes as needed. Profit! |
Thank you, now that I have a work base, I think everything will go more easily ! 💟 If nobody has anything to add, I think the issue is resolved ! Take a beer for me! |
After multiple tests (successful, obviously), I asked myself a question: why common-hook, by default, only returned
It sounds much better, so we can keep a clean code base by not changing people's habits ! What do you think about a pull request @eddyystop ? |
The default generates messages in the format commonly required by client-side form handling repo's. This way people don't have to do that conversion themselves. If you are using your own or another type of form handler, you can get the messages you want by injecting your own function. In any case, it is way to late to change the default. Too many programs depend on the way things are. |
Leaving this open to keep a note of perhaps someday interfacing ajv's i18n capabilities. |
Ok, no problems 😁
Thanks for your help and your support
~Ps: remember to close the issue !~ Oups !
Le lun. 7 août 2017 à 21:32, Eddyystop <[email protected]> a écrit :
The default generates messages in the format commonly required by
client-side form handling repo's. This way people don't have to do that
conversion themselves.
If you are using your own or another type of form handler, you can get the
messages you want by injecting your own function.
In any case, it is way to late to change the default. Too many programs
depend on the way things are.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#242 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AYPoIdoHRquosF4OXdxPI072rl8R4Tj0ks5sV2ZigaJpZM4Ouuti>
.
--
********************
Les informations contenues dans ce courriel sont strictement
confidentielles et réservées à l’usage de la ou des personne(s)
identifiée(s) comme destinataire(s). Si vous avez reçu ce message par
erreur, merci de le supprimer et d’en avertir immédiatement son expéditeur.
L’usage des informations contenues dans ce message ou les documents qui y
sont attachés est interdit.
Le contenu de ce message ne contient aucun engagement et les opinions qui y
sont exprimées n’engagent pas l'Expéditeur.
L'Expéditeur décline sa responsabilité pour la propagation de tout virus ou
toute perte, transformation, dégradation d’un contenu transporté par ce
courriel...
********************
|
Note added to Buzzard version http://192.168.1.130:4000/v1/feathers-hooks-common/index.html#validateSchema |
feathersjs-ecosystem/docs#797 was left at
I added this to the docs
I'm not sure how the above would be used with validateSchema. Perhaps validateSchema has to be modified around https://github.com/feathersjs/feathers-hooks-common/blob/master/src/services/validate-schema.js#L65
Could you tell me what you determined when you look into it? Thanks.
The text was updated successfully, but these errors were encountered: