当前位置: 首页 > news >正文

Spring-boot读书笔记一弄懂ConstraintValidatorPassword, String

In ConstraintValidator<Password, String>, the two generic type parameters are:

First parameter: Password

  • This is the annotation type that this validator handles
  • It's a custom validation annotation (like @Password) that you would create
  • When someone uses @Password on a field, this validator will be called
  • Example: @Password private String userPassword;

Second parameter: String

  • This is the data type of the value being validated
  • It tells the validator what type of object it will receive in the isValid() method
  • In this case, it expects a String value (the password)
  • The isValid(String password, ...) method parameter matches this type

How it works:

  • You create a @Password annotation
  • Apply it to a String field: @Password String myPassword
  • When validation runs, this validator receives the String value
  • The isValid() method validates that String and returns true/false

Other examples:

  • ConstraintValidator<Email, String> - validates email strings
  • ConstraintValidator<Min, Integer> - validates minimum integer values
  • ConstraintValidator<NotNull, Object> - validates any object is not null

The generic types ensure type safety between the annotation and the value being validated.

http://www.jsqmd.com/news/173276/

相关文章:

  • 第72天(中等题 数据结构)
  • 【课程设计/毕业设计】基于springboot和vue的电子书阅读、社交讨论、内容创作阅读交流分享平台【附源码、数据库、万字文档】
  • Java毕设项目推荐-基于SpringBoot的广西旅游景点数据分析系统与设计【附源码+文档,调试定制服务】
  • Swift 类型转换
  • Java毕设项目:基于Springboot的牧场管理系统的设计与实现(源码+文档,讲解、调试运行,定制等)
  • 融合多维特征的传统与深度学习AES系统对比研究
  • Java指针p
  • Java计算机毕设之基于springboot和vue的阅读交流分享平台vue+springboot小说创作与在线阅读分享平台系统(完整前后端代码+说明文档+LW,调试定制等)
  • 2025 最新!9个AI论文平台测评:本科生毕业论文写作全攻略
  • Java毕设项目:基于SpringBoot的广西旅游景点数据分析系统与设计(源码+文档,讲解、调试运行,定制等)
  • 生命周期评价(LCA)核心方法与软件实操指南:以OpenLCA和GREET为例
  • 生命周期评价(LCA)核心方法与软件实操指南:以OpenLCA和GREET为例
  • 【毕业设计】基于SpringBoot和Vue的新闻发布管理系统的设计与实现(源码+文档+远程调试,全bao定制等)
  • 腾讯开源10亿参数3D动作模型,小米MiMo公测延续至2026年,MiniMax M2.1编程模型发布,京东上线自营机器人租赁业务
  • 【接口测试】2_项目实战 _接口自动化测试框架
  • 计算机Java毕设实战-基于SpringBoot的广西旅游景点数据分析系统与设计【完整源码+LW+部署说明+演示视频,全bao一条龙等】
  • 基于图注意力的时空数据因果链推理分析
  • 从采集到销毁:大数据生命周期全流程深度解析
  • 【计算机毕业设计案例】基于Spring Boot框架的牧场数字化管理系统设计与实现基于Springboot的牧场管理系统的设计与实现(程序+文档+讲解+定制)
  • 【毕业设计】基于SpringBoot的爱豆明星周边销售管理系统的设计与实现(源码+文档+远程调试,全bao定制等)
  • 【接口测试】3_项目实战 _封装Tpshop商城登录接口
  • 【毕业设计】基于SpringBoot的广西旅游景点数据分析系统与设计(源码+文档+远程调试,全bao定制等)
  • 技术人别再「埋头写代码」:一场好演讲,能让你的价值翻10倍
  • 工地目标检测数据集999张13种类别VOC+YOLO格式
  • 光量子计算机再达“量子优势”,意义何在?
  • Electron for 鸿蒙PC项目实战案例之水果消消乐 - 详解
  • HPE OneView高危漏洞CVE-2025-37164剖析:未经认证的远程代码执行
  • jQuery 杂项方法
  • 学长亲荐8个AI论文软件,助你轻松搞定本科论文!
  • C 标准库 - `<stdarg.h>`