Request body validation in Node with yup | validating JSON schema

  Рет қаралды 13,258

Jan Goebel

Jan Goebel

Күн бұрын

Пікірлер: 36
@jgoebel
@jgoebel 4 жыл бұрын
Let me know what you think about this video. As always, feel free to write a comment if you want me to cover a particular topic
@jacksonlloyd1519
@jacksonlloyd1519 4 жыл бұрын
Great Video! Do you think Yup is a bad idea to mix with typescript? Seems like you'd be validating the already defined type
@jgoebel
@jgoebel 4 жыл бұрын
thanks, I'm glad you like it 👍 I think Typescript the benefit of this library is certainly not as big as with plain JS because with Typescript you can already define the types of the incoming payload. However, it could be useful to do some custom validation (validating that a string has a specific length or matches a Regex, is not null and so on). If I were to start a new Typescript project, I'd probably try to get along without it first and then when there is a need for more fine-grained validation, then it would probably make sense to use it.
@RicksSolutions
@RicksSolutions 4 жыл бұрын
Congratulations, or as they say here in Brazil, "Você está de Parabéns"... very good
@jgoebel
@jgoebel 4 жыл бұрын
thanks 👍
@patrykszindler7215
@patrykszindler7215 2 жыл бұрын
You're amazing, thank you for such good content that is for free... :)
@jgoebel
@jgoebel 2 жыл бұрын
You're very welcome!
@pradeepasandaruwan4896
@pradeepasandaruwan4896 3 жыл бұрын
Thank you so much
@jgoebel
@jgoebel 3 жыл бұрын
You're most welcome Pradeepa 👍
@arifali1063
@arifali1063 4 жыл бұрын
Great video always teaching us something useful, thanks for everything
@jgoebel
@jgoebel 4 жыл бұрын
glad you enjoyed it 👍
@joeygarcia7826
@joeygarcia7826 2 жыл бұрын
Nice video! I'll be looking for that Dependency Injection video!
@jgoebel
@jgoebel 2 жыл бұрын
I already created a series about dependency injection: kzbin.info/www/bejne/iqnblaScnbKIpKs
@deveshteotia5179
@deveshteotia5179 3 жыл бұрын
Very Informative, Great Work.
@jgoebel
@jgoebel 3 жыл бұрын
thx devesh, I'm glad you found it useful 👍
@ghumakkad_baccha
@ghumakkad_baccha 3 жыл бұрын
Great . I just felt its only for me. :) thanks you so much
@jgoebel
@jgoebel 3 жыл бұрын
you're welcome Satyendra 👍
@igorpavlenko411
@igorpavlenko411 4 жыл бұрын
great video man, easy explanation
@jgoebel
@jgoebel 4 жыл бұрын
Thanks, I'm glad you liked it 👍
@murilovercellino
@murilovercellino 4 жыл бұрын
Great video! Congrats
@jgoebel
@jgoebel 4 жыл бұрын
thx
@douglasricardo9129
@douglasricardo9129 4 жыл бұрын
Amazing, I have been studying node for a while, and for sure your content is on the top list. Thanks for sharing such good knowledge. What you commonly use for document an API? openSwagger or another tool. What are your thoughts about moving from express to KOA or other library? Could you indicate some good books about node. And again AWASOME. Thanks a million.
@jgoebel
@jgoebel 4 жыл бұрын
thanks, I'm glad you like it. 1. Yes Swagger / Open API is actually my preferred tool, simply because it is quite easy to maintain. The only thing to always remember is to not expose the Swagger when you run in prod 2. I've never used Koa, express could do everything out of the box and that's why I haven't looked at it so far 3. I haven't looked at books when I got into Node, simply because I found that most of them were quite incomplete or outdated. I basically tried to learn Node and then tried to transfer best practices I knew from other technologies over to Node (like having a service layer for example. I think I can recommend to official express documentation though
@rao180677
@rao180677 Ай бұрын
Nice. But I'm looking for a way to generate that schema from an open api spec. This way, it would all depend on the spec. Is there a way to do it?
@codinginflow
@codinginflow Жыл бұрын
Would you repeat the validation logic in Mongoose's model (using the inbuilt validator functions) or is that obsolete with this approach?
@jgoebel
@jgoebel Жыл бұрын
Hi Florian, my preferred approach is to fail as early as possible, so if there are issues with the received payload, it should fail right away. In this case, you also do not need validators in Mongoose which would duplicate the validation logic and which would be harder to maintain
@codinginflow
@codinginflow Жыл бұрын
@@jgoebel Yea I came to the same conclusion. Thank you very much 👍
@RicksSolutions
@RicksSolutions 4 жыл бұрын
Very good ... and how would you do for the function to validate the data sent by parameter ? Id for example...
@jgoebel
@jgoebel 4 жыл бұрын
you can use yup's test method to write a custom validation: github.com/jquense/yup#mixedvalidatesyncvalue-any-options-object-any
@harikrishnan-pr6qk
@harikrishnan-pr6qk 3 жыл бұрын
Great Video. Is this approach we get only single error back after validation when the request body actually has many errors. How to validate all fields and return all errors by using yup validation? Is it possible?
@jgoebel
@jgoebel 3 жыл бұрын
Hi hari, you can set abortEarly to false and then it will return all validation errors. I totally agree that this is better and that this should be the default behaviour. github.com/jquense/yup/issues/44
@makeit_studio
@makeit_studio 4 жыл бұрын
thank you very much sir! can you please open repository for this video?
@jgoebel
@jgoebel 4 жыл бұрын
sure, sry forgot to make it public. Should be good now
@makeit_studio
@makeit_studio 4 жыл бұрын
@@jgoebel thanks againn
@IranzinhoBRG
@IranzinhoBRG 4 жыл бұрын
The github repo isn't available anymore. Good video btw
@jgoebel
@jgoebel 4 жыл бұрын
Sry for the inconvenience. I forgot to make the repo public. Now it is public.
Ajv JSON schema validation
14:51
Jan Goebel
Рет қаралды 19 М.
Backend API Validation Tutorial w/ YUP and ExpressJS
18:31
PedroTech
Рет қаралды 12 М.
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
IL'HAN - Qalqam | Official Music Video
03:17
Ilhan Ihsanov
Рет қаралды 700 М.
Node winston logging | logging in Node
28:34
Jan Goebel
Рет қаралды 44 М.
Express JS #10 - Validation
31:33
Anson the Developer
Рет қаралды 16 М.
How is this Website so fast!?
13:39
Wes Bos
Рет қаралды 1,3 МЛН
Part 1 - JSON Schema For API Validation
39:23
Ganbaro Digital
Рет қаралды 20 М.
JSON Schema Validation in Python: Bring Structure Into JSON
13:45
Node.js API Authentication With JWT
23:01
Traversy Media
Рет қаралды 559 М.
Node Objection.js tutorial with knex and Postgres | Node SQL ORM
44:23