Skip to content
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

added correct link #13301

Merged
merged 2 commits into from Apr 21, 2023
Merged

added correct link #13301

merged 2 commits into from Apr 21, 2023

Conversation

IslandRhythms
Copy link
Collaborator

No description provided.

lib/schematype.js Outdated Show resolved Hide resolved
@vkarpov15 vkarpov15 merged commit bc69fc8 into master Apr 21, 2023
33 of 34 checks passed
@vkarpov15 vkarpov15 deleted the IslandRhythms/fix-docs branch April 21, 2023 17:58
@Andrey-Yur
Copy link

Andrey-Yur commented Apr 21, 2023

@vkarpov15 @IslandRhythms Sorry, link does not work yet. But, I am looking for information (the list) with _other template keywords besides {PATH} and {VALUE}_ So, the question regarding the basic templates in mongoose. Where can I see them?
image

@hasezoey
Copy link
Collaborator

Sorry, link does not work yet.

the link you have in your screenshot is the link that this PR replaces, not adds and the PR's changes are not live yet (website only updates when a version releases)

But, I am looking for information (the list) with other template keywords besides {PATH} and {VALUE}

there does not seem to be any documentation about that yet, but for reference:

  • CastError templates can be seen at

    mongoose/lib/error/cast.js

    Lines 126 to 134 in bc69fc8

    function formatMessage(model, kind, stringValue, path, messageFormat, valueType, reason) {
    if (messageFormat != null) {
    let ret = messageFormat.
    replace('{KIND}', kind).
    replace('{VALUE}', stringValue).
    replace('{PATH}', path);
    if (model != null) {
    ret = ret.replace('{MODEL}', model.modelName);
    }
  • ValidationError supports templates based on the properties, see
    msg = msg.replace('{' + propertyName.toUpperCase() + '}', properties[propertyName]);
    and
    it('replaces properties in a message', function() {
    const props = { base: 'eggs', topping: 'bacon' };
    const message = 'I had {BASE} and {TOPPING} for breakfast';
    const result = ValidatorError.prototype.formatMessage(message, props);
    assert.equal(result, 'I had eggs and bacon for breakfast');
    });

Note: i dont know if what i said is totally correct, i just looked at the format functions themself (not the full call chain)

@Andrey-Yur
Copy link

Andrey-Yur commented Apr 24, 2023

@hasezoey @vkarpov15 Thanks for your answer! I would be grateful if you would give a link where I can find ALL the available templates keywords. From provided info, for example, it is clear for me since now, and I guess that in additional to CastError/ValidateError templates were just shared by you, are present something like {SCHEMA}, {DOCUMENT} and etc.,does it? Could you share whole set of the avaible mongoose templates too, pls?

@hasezoey
Copy link
Collaborator

Could you share whole set of the avaible mongoose templates too, pls?

as i said in the earlier comment, there is currently no documentation for all templates available (see #13311) and the listed code example i gave were just quick findings from me (i dont know if they are everything or if they are even correct)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Link to a the page with the description of templates keywords does not work on the site with docs
4 participants