Skip to content

自定义验证码校验

Yugang Zhou edited this page Jun 13, 2019 · 1 revision

为避免User Agent传入非法的验证码,com.thebund1st.daming.core.SmsVerificationCodePattern提供了抽象,你可以在项目中扩展该接口来定制校验机制。

默认的校验实现

DamingSmsVerificationCodePattern提供了开箱即用的实现,默认校验为6位数字

自定义的校验实现

任何注册到Spring ApplicationContextSmsVerificationCodePattern都可以替换Daming的默认实现:

@Component
public class MySmsVerificationCodePattern implements SmsVerificationCodePattern {

    @Override
    public boolean matches(SmsVerificationCode value) {...}
}

Clone this wiki locally