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
refactor: rename request.validate
to request.validateInput
#4139
refactor: rename request.validate
to request.validateInput
#4139
Conversation
docs/Reference/Request.md
Outdated
// or | ||
|
||
const validate = request | ||
.getSerializationFunction('body') |
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.
misprint: the serialization function
docs/Reference/Request.md
Outdated
validate({ foo: 0.5 }) // false | ||
``` | ||
|
||
See [.compilaValidationSchema(schema, [httpStatus])](#compileserializationschema) |
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.
See [.compilaValidationSchema(schema, [httpStatus])](#compileserializationschema) | |
See [.compilaValidationSchema(schema, [httpStatus])](#compilevalidationschema) |
docs/Reference/Request.md
Outdated
This function will compile a validation schema and | ||
return a function that can be used to validate data. | ||
The function returned (a.k.a. _validation function_) is compiled | ||
by using the provided `SchemaControler#ValidationCompiler`. |
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.
Should it be a link?
docs/Reference/Request.md
Outdated
// or | ||
|
||
const validate = request | ||
.compileSerializationSchema({ |
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.
misprint: the serialization is not involved here and it returns a string
docs/Reference/Request.md
Outdated
|
||
Note that you should be careful when using this function, as it will cache | ||
the compiled valiadtion functions based on the schema provided. If the | ||
schemas provided is mutated or changed, the serialization functions will not |
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.
schemas provided is mutated or changed, the serialization functions will not | |
schemas provided are mutated or changed, the validation functions will not |
docs/Reference/Request.md
Outdated
the compiled valiadtion functions based on the schema provided. If the | ||
schemas provided is mutated or changed, the serialization functions will not | ||
detect that the schema has been altered and for instance it will reuse the | ||
previously compiled serialization function, as the cache is based on |
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.
previously compiled serialization function, as the cache is based on | |
previously compiled validation function, as the cache is based on |
docs/Reference/Request.md
Outdated
a totally new schema (object), otherwise the implementation won't benefit from | ||
the cache mechanism. | ||
|
||
:Using the following schema as example: |
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.
:Using the following schema as example: | |
Using the following schema as an example: |
const validate = request.compileValidationSchema(schema1) | ||
|
||
// Later on... | ||
schema1.properties.foo.type. = 'integer' |
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.
schema1.properties.foo.type. = 'integer' | |
schema1.properties.foo.type = 'integer' |
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.
Note for myself: Do not write documentation late in the night 😅
validate({ hello: 'world' }) // false | ||
``` | ||
|
||
Note that you should be careful when using this function, as it will cache |
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.
I wonder if we should just link a blog post (I volunteer to write it) to explain this.
I think it is too technical and the user may loose the focus on the "big picture"
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.
Agree, didn’t find a way to make it less verbose. Actually I think a Blog post will explain pretty what’s about, happy to be part if I can be helpful somehow 🙂
docs/Reference/Request.md
Outdated
// or | ||
|
||
request | ||
.serializeInput({ hello: 'world'}, 'query') // false |
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.
.serializeInput({ hello: 'world'}, 'query') // false | |
.validateInput({ hello: 'world'}, 'query') // false |
docs/Reference/Request.md
Outdated
} | ||
} | ||
}, 200) | ||
validate({ hello: 'world' }) // false |
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 about renaming it to validateInput
? (as serializeInput
)
We did not land this feature yet
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.
Sure, I think it can follow the same pattern as with the serializeInput
👍
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
request.validate
to request.validateInput
Why need to rename
|
This feature is not yet shipped, so we can change it. I suggested it because the |
Co-authored-by: 小菜 <xtx1130@gmail.com>
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
@climba03003 is this good to land? |
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.
It is a refactor on name and document update.
I believe it is good to go.
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.
ref: #3970
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Checklist
npm run test
andnpm run benchmark
and the Code of conduct