锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产亚洲欧美中文,日韩高清国产一区在线,四虎精品在线http://www.aygfsteel.com/paulwong/category/55377.htmlzh-cnThu, 29 Jul 2021 08:14:13 GMTThu, 29 Jul 2021 08:14:13 GMT60JSR-303 Bean Validation - Grouping Javax Validation Constraintshttp://www.aygfsteel.com/paulwong/archive/2021/07/29/435937.htmlpaulwongpaulwongThu, 29 Jul 2021 02:00:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/07/29/435937.htmlhttp://www.aygfsteel.com/paulwong/comments/435937.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/07/29/435937.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435937.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435937.html@NotBlank(message = "Missing ID_IMG_CHECK.")
浠ヤ笂鏍囩榪涜楠岃瘉鏃舵槸鏃犳潯浠墮獙璇侊紝濡傛灉鎯沖湪鐗瑰畾鏉′歡涓嬫墠楠岃瘉錛屽垯涓嶉傜敤銆?br />
浜庢槸鎵嶆湁濡備笅璁懼畾錛?br />
@NotBlank(message = "Missing ID_IMG_CHECK.", groups = {GroupA.class} )

鎵嬪姩楠岃瘉錛?br />
Class<?> [] classArray = classList.toArray(new Class<?>[0]);
LOGGER.info("subVersion : {}, Validate class : {}", subVersion, classNameList);
CompositeException compositeException = new CompositeException();
Set<ConstraintViolation<QueryKycResultDetail>> groupSet = validator.validate(queryKycResultDetail, classArray);

https://www.baeldung.com/javax-validation-groups

paulwong 2021-07-29 10:00 鍙戣〃璇勮
]]>
JSR-303 Bean Validation - @Size鍜孈Max@Min鐨勫尯鍒?/title><link>http://www.aygfsteel.com/paulwong/archive/2021/04/29/435867.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Thu, 29 Apr 2021 01:55:00 GMT</pubDate><guid>http://www.aygfsteel.com/paulwong/archive/2021/04/29/435867.html</guid><wfw:comment>http://www.aygfsteel.com/paulwong/comments/435867.html</wfw:comment><comments>http://www.aygfsteel.com/paulwong/archive/2021/04/29/435867.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/paulwong/comments/commentRss/435867.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/paulwong/services/trackbacks/435867.html</trackback:ping><description><![CDATA[<p style="margin-top: 0px; margin-right: 0px; margin-bottom: var(--s-prose-spacing); margin-left: 0px; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; box-sizing: inherit; clear: both; color: #242729; background-color: #ffffff;"><code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">@Min</code> and <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">@Max</code> are used for validating numeric fields which could be <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">String</code>(representing number), <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">int</code>, <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">short</code>, <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">byte</code> etc and their respective primitive wrappers.<br /><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: var(--s-prose-spacing); margin-left: 0px; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; box-sizing: inherit; clear: both; color: #242729; background-color: #ffffff;"><code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">@Size</code> is used to check the length constraints on the fields.<br /><br /></p><p style="margin: 0px; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; box-sizing: inherit; clear: both; color: #242729; background-color: #ffffff;">As per documentation <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">@Size</code> supports <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">String</code>, <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">Collection</code>, <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">Map</code> and <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">arrays</code> while <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">@Min</code> and <code style="margin: 0px; padding: 2px 4px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: var(--black-075); white-space: pre-wrap; color: var(--black-800); border-radius: 3px;">@Max</code> supports primitives and their wrappers. See the <a rel="noreferrer" style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; box-sizing: inherit; cursor: pointer; user-select: auto;">documentation</a>.</p><img src ="http://www.aygfsteel.com/paulwong/aggbug/435867.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/paulwong/" target="_blank">paulwong</a> 2021-04-29 09:55 <a href="http://www.aygfsteel.com/paulwong/archive/2021/04/29/435867.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>JSR-303 Bean Validation - Date String Validation http://www.aygfsteel.com/paulwong/archive/2021/02/25/435810.htmlpaulwongpaulwongThu, 25 Feb 2021 01:44:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/02/25/435810.htmlhttp://www.aygfsteel.com/paulwong/comments/435810.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/02/25/435810.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435810.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435810.html鍏跺疄鍙互鏂板姞涓涓柟娉曡繑鍥濪ate綾誨瀷錛屽啀閰嶅悎@Future@Past 榪涜楠岃瘉銆?br />
@Future(message = "Invalid CN_ID_INFO.EXPIRE_DATE.")
private LocalDate getValidExpireDate() {
    try {
        return LocalDate.parse(this.dateString, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    } catch (Exception e) {
        return null;
    }
}

姝ゆ柟娉曞dateString榪涜瑙i噴錛岃繑鍥濴ocalDate錛屽鏋渄ateString涓虹┖鎴栨牸寮忛敊璇紝鍒欒繑鍥炵┖錛屽啀閰嶅悎@Future 榪涜鏄惁鏈潵鏃ユ湡鐨勯獙璇併?br />


paulwong 2021-02-25 09:44 鍙戣〃璇勮
]]>
JSR-303 Bean Validation - Conditional Validationhttp://www.aygfsteel.com/paulwong/archive/2021/02/25/435809.htmlpaulwongpaulwongThu, 25 Feb 2021 01:24:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/02/25/435809.htmlhttp://www.aygfsteel.com/paulwong/comments/435809.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/02/25/435809.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435809.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435809.html榪欑鏂規(guī)硶閬垮厤浜嗚嚜瀹氫箟鏍¢獙鍣ㄨ屽鍔犵被銆?br />https://www.chkui.com/article/java/java_bean_validation

@AssertTrue(message = "Missing BANK_CARD_IMG_INFO.IMG")
private Boolean getValidImg() {
    if(YNEnum.Y.code.equals(super.getNeedChecked())) {
            return StringUtils.hasText(this.img);
        }
        return null;//igore checking.
}

榪欎釜鏄綋needChecked涓篩鐨勬椂鍊欐墠鎵ц媯鏌mg鍙橀噺鏄惁涓虹┖銆?br />鏈夊嚑鐐規(guī)敞鎰忥細
  1. 鏂規(guī)硶鍚嶇О瑕佷互get寮澶?br />
  2. 榪斿洖綾誨瀷鐢˙oolean錛岃屼笉鐢╞oolean
  3. 榪斿洖鍊兼湁涓夌錛歵rue,false,null濡傛灉鏄痭ull鍒欏綋鎴愰氳繃錛屼笌true鐨勭粨鏋滀竴鏍?/li>


paulwong 2021-02-25 09:24 鍙戣〃璇勮
]]>
JSR-303 Bean Validationhttp://www.aygfsteel.com/paulwong/archive/2021/01/28/435786.htmlpaulwongpaulwongThu, 28 Jan 2021 02:35:00 GMThttp://www.aygfsteel.com/paulwong/archive/2021/01/28/435786.htmlhttp://www.aygfsteel.com/paulwong/comments/435786.htmlhttp://www.aygfsteel.com/paulwong/archive/2021/01/28/435786.html#Feedback0http://www.aygfsteel.com/paulwong/comments/commentRss/435786.htmlhttp://www.aygfsteel.com/paulwong/services/trackbacks/435786.html
JSR-303 Bean Validation鍒欐彁渚涗簡榪欐牱鐨勪究鎹楓?br />
鍙鍦↗AVA BEAN涓渶瑕侀獙璇佺殑瀛楁鍔燖NotNull榪欑鏍囩錛岀劧鍚庡湪SERVISE涓殑杈撳叆鍙傛暟涓姞@Valid鏍囩錛屽垯灝辨縺媧婚獙璇佹祦紼嬨?br />涔熷彲浠ョ紪紼嬬殑鏂瑰紡鑷繁楠岃瘉錛?br />
@MessageEndpoint
//@Validated
public class MqMessageCcdValidator {
    
    private static final Logger LOGGER = LoggerFactory.getLogger(MqMessageCcdValidator.class);
    
    @Autowired
    private Validator validator;
    
    @ServiceActivator
    public MqMessage<CcdRequest> validate(/* @Valid */ Message<MqMessage<CcdRequest>> requestMessage) {
        Set<ConstraintViolation<MqMessage<CcdRequest>>> set = validator.validate(requestMessage.getPayload());
        if(CollectionUtils.isNotEmpty(set)) {
            CompositeException compositeException = new CompositeException();
            set.forEach(
                constraintViolation -> {
                                            LOGGER.info("{}", constraintViolation);
                                            ReqInfoValidationException exception =
                                                    new ReqInfoValidationException(constraintViolation.getMessage());
                                            compositeException.addException(exception);
                                       }
            );
            throw new MessageHandlingException(requestMessage, compositeException);
        }
        
        return requestMessage.getPayload();
    }

}

鑷畾涔夐獙璇佽鍒?br />鍙敤鏍囩鏉ュ仛錛屼互涓嬩負楠岃瘉鎵嬫満鍙風殑瑙勫垯錛?br />
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.ReportAsSingleViolation;
import javax.validation.constraints.Pattern;

@Retention(RUNTIME)
@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE })
@Constraint(validatedBy = {})
@ReportAsSingleViolation
@Pattern(regexp = "^1[3-9]\\d{9}$")
public @interface ChinaPhone {
    String message() default "Invalid Chinese mobile No.";
    Class<?>[] groups() default {};
    Class<? extends Payload>[] payload() default {};
}

濡傛灉姣旇緝澶嶆潅鐨勯獙璇佽鍒欙紝鍒欏弬瑙侊細
https://reflectoring.io/bean-validation-with-spring-boot/#implementing-a-custom-validator

How to use Java Bean Validation in Spring Boot
https://nullbeans.com/how-to-use-java-bean-validation-in-spring-boot/

Complete Guide to Validation With Spring Boot
https://reflectoring.io/bean-validation-with-spring-boot/

Spring JMS Validate Messages using JSR-303 Bean Validation
https://memorynotfound.com/spring-jms-validate-messages-jsr-303-bean-validation/

Spring REST Validation Example
https://mkyong.com/spring-boot/spring-rest-validation-example/

Spring Boot 鏁村悎 Bean Validation 鏍¢獙鏁版嵁

https://blog.csdn.net/wangzhihao1994/article/details/108403732


paulwong 2021-01-28 10:35 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 连州市| 达孜县| 朝阳区| 静安区| 九台市| 方山县| 台北县| 泰和县| 江华| 山东省| 景德镇市| 宣恩县| 嘉义市| 昭苏县| 桑日县| 景谷| 迁西县| 平阳县| 来凤县| 彭水| 阿拉善左旗| 玛纳斯县| 肃宁县| 达拉特旗| 江都市| 洪泽县| 时尚| 天柱县| 开平市| 思茅市| 海阳市| 晋江市| 基隆市| 新田县| 徐汇区| 广河县| 汪清县| 抚顺市| 五常市| 射阳县| 陆河县|