谢谢, exactly the type of validator, almost, I was looking for, and with the explanation everything was clear as a day, thanks Miss Xing!
@Milt17p4 жыл бұрын
One of the best tutorials I've seen. Thank you!
@flopani50593 жыл бұрын
This was very explanatory and it worked from the first try on my own custom validation!
@nazmulhassanmd32222 жыл бұрын
Thank you so much …. I have learned a lot from this video
@laogedj3 жыл бұрын
Great video, easy to understand, thank you Xing
@hitterobr3 жыл бұрын
You saved my life, thank's
@alouiachref99323 жыл бұрын
Big love and thank you , you are the best
@ametsoro55803 жыл бұрын
Really enjoy this tutorial thanks !!!
@cornelliushatcher2 жыл бұрын
Very useful stuff, thanks for uploading.., any idea how List can be validated using hibernate validator?
@elmarvo7505 Жыл бұрын
Hello, thank you for the video! Can you or someone else please explain the lines 15 and 16 in class Age? Class[] groups() default {}; and the Payload thing? What does it do and why do I need it? Thank you
@krige3 жыл бұрын
Great video, thanks! It would be very nice if you would share the source of your knowledge in the video description. I would name the class "AgeValidator" instead of "AgeValidation".
@amitdubey68673 жыл бұрын
not getting error messages displayed on jsp while validation is working.. any help. thank you.
@AliHassan-ty2me Жыл бұрын
same issue do you configure this out ?
@EduardoSilva-us1jp3 жыл бұрын
Great, thanks. I have a question. I need to validate a field but I need to access the database to do so. I'd like to know whether it's better to have this validation in the DTO which has an id for the validation class to use to access the database, or in the DAO layer which doesn't have the id but the entity itself, for now, it's in the DTO.
@EduardoSilva-us1jp3 жыл бұрын
For ex: // Given from the Dto isValid(Long id, Ctx...){ repository.findbyId(id) ... Processing validation } // Given from DAO isValid(Entity x, ctx...){ repository.findById(x.getId()); // Process }
@Vlfkfnejisjejrjtjrie3 жыл бұрын
@@EduardoSilva-us1jp your DTO should be bare bones and only pass data, it shouldn't be calling the repo.findby. Pass the data to your entity and let it do the work. DTO ->Service->Entity-> Repo. You could use a request DTO and Response DTO to transfer data to/from Service. The service will be referenced from calling Controller.
@shuuheihisagi31483 жыл бұрын
@@Vlfkfnejisjejrjtjriehey, thanks. What was actually calling repo.findby was the class implementing ConstraintValidator, by annotating the dto, its field (dto field) which was an integer was being sent to the validator class so it would use the id and the repo.findby. When annotating the actual object, the validator was getting the current object field
@shuuheihisagi31483 жыл бұрын
My dto would only contain both lombok and validation annotations provided by starter validation and annotations created just like in the video, is that ok?
@Vlfkfnejisjejrjtjrie3 жыл бұрын
@@shuuheihisagi3148 anything is okay, depending on your needs. Using lombok is common, but I wouldn't call validation fro a DTO. It's commonly used as a convenience mechanism to move groups of data from one p,ace to another.
@naveenkumar-vf6pk3 жыл бұрын
hi if we want supply the annotation to class level and field level as well as method level then how can we configure in customvalidator
@worchock3 жыл бұрын
thanks, greeting from colombia
@krige3 жыл бұрын
Is it possible to print the value being invalidated in the constraint annotation String message() default?
@helanomiguel37834 жыл бұрын
One thing that is not clear to me is how can I access the validation message using a Java code? I thought that the Annotation API would throw a new ValidationExcepion, but i did not happen that way
@vdm20023 жыл бұрын
What about the explanation for the Initialize method?
@ashwinikumar91384 жыл бұрын
How to create custom annotation to return string padding
@somnathchaudhuri282224 жыл бұрын
I have written two validation logic in isValid method and want to display different single message based on my if else condition . Can u tell me how to do that.
@MissXing4 жыл бұрын
You need to explain more, the if/else condition is based on what? When we add custom annotation, we only have 1 class to perform checking. So only 1 isValid() being called for 1 annotation. So if based on the value, just add if/else in isValid(). If not based on the value, I don't know which condition you're mentioning here.
@Jeptxxle4 жыл бұрын
How can I set the message depending on users locale?
@manikolla34374 жыл бұрын
hi miss xing that was wonderful explaination have given about the custom bean validation but i have one question what is difference java bean validation and spring bean validation(i mean spring has release newer version of validator interface) ?
@MissXing4 жыл бұрын
Two different ways to implement bean validation. Jave doesn't have bean implementation of validator. Hibernate validator is the implementation of bean validation specification. Spring can integrate with it. The other way is you use spring validator interface without using Hibernate validator implementation.
@vishnugovindan85504 жыл бұрын
Is there anyway to get the particular class level bean validation error messages so that we can display it next to the age input box (rather than being binded to ) ??
@vishnugovindan85504 жыл бұрын
I think I have figured it out You have to map this constraint violation to the required field to that it can get picked up by @Override public boolean isValid(User user, ConstraintValidatorContext context) { if(user.getAge() != null) { Period period = Period.between(user.getBirthday(),LocalDate.now()); context.buildConstraintViolationWithTemplate(errorMessage).addPropertyNode("age").addConstraintViolation(); return user.getAge() == period.getYears(); } return false; }
@МаксимБочковВолодимирович4 жыл бұрын
Thank you!
@AboiGaming3 жыл бұрын
Great Work
@saddammd4 жыл бұрын
Nice explanation
@prabhatgaur11504 жыл бұрын
How to validate list of user
@MissXing4 жыл бұрын
This is an interesting question. if use a form, how can you add a collection of user, what's the data binding look like? You must have another wrapper object in order to submit collection, if in this case, a collection will be validated one by one.
@prabhatgaur11504 жыл бұрын
I've written my custom constraints in user method resultValidations() I don't like validation framework. Stream can filter collection in one line