-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat(docs): add validation docs #4874
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general, just have some nitpicks 😄
calling a service to check if an address is valid. You can also create global, | ||
class-level or method-level interceptors. | ||
|
||
You can create interceptors using the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a tiny nitpick: You can create interceptors using the
.. -> Interceptors can be created by...
as we have ' You can also create global...' above.
docs/site/Validation-ORM-layer.md
Outdated
The validation in the ORM layer is to make sure the data being added or updated | ||
to the database is valid. | ||
|
||
There is validation coming from the legacy juggler. The validation is enforced |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps provide a link to legacy juggler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is validation coming from the legacy juggler
There is some validation done in legacy juggler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation is enforced at the database level, there is not much additional constraints we can set
beyond the database ones
The validation is enforced at the database level, so there aren't many additional constraints we can set
beyond the database ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can mention schema constraints enforced by specific DBs, such as unique index.
For preprocessing against CRUD operations, we can refer to https://loopback.io/doc/en/lb4/migration-models-operation-hooks.html.
## Add validation function in the Controller method | ||
|
||
The simplest way is to apply the validation function in the controller method, | ||
that is: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is
is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe like this?
The simplest way is to apply the validation function in the controller method.
For example:
@strongloop/loopback-maintainers, regarding the discussion around adding an example repo for validation, I have my app in https://github.com/dhmlau/loopback4-validation-example. Any objection to create another example in loopback-next? I don't mind either way, just don't know if it worths a separate example for that. Thanks! |
@dhmlau Maybe we can add some information about using 3rd party validation libraries, such as: |
dfc5d08
to
5820df2
Compare
@raymondfeng @emonddr @agnes512 @achrinza, I've updated the PR based on the changes in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 nice work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👏
docs/site/Validation.md
Outdated
Let's take a closer look at how validation can be added in the following layers: | ||
|
||
- [REST layer](Validation-REST-layer.md) | ||
- [Controller layer](Validation-controller-layer.md) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe have the description consistent with the url and title?
Validation in the Controller, Repository and Service Layer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be your suggested change?
If I understand your comment correctly, since the sentence before the bullets are “… look at how validation can be added in the following layers:“, so it won’t make sense to make the bullet:
from REST layer
to validation in REST layer
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh let me clarify, I meant using "Controller, Repository and Service layer"
8429463
to
dc7ed3b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Add more documentation on how to add validation to a LoopBack application.
Propose to add the validation docs under "Usage scenarios"
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated👉 Check out how to submit a PR 👈