SaveInfo.Builder.SetValidator(IValidator) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
設定一個物件用來驗證使用者輸入——如果輸入無效,則不會顯示自動填充存檔的 UI。
[Android.Runtime.Register("setValidator", "(Landroid/service/autofill/Validator;)Landroid/service/autofill/SaveInfo$Builder;", "", ApiSince=27)]
public Android.Service.Autofill.SaveInfo.Builder SetValidator(Android.Service.Autofill.IValidator validator);
[<Android.Runtime.Register("setValidator", "(Landroid/service/autofill/Validator;)Landroid/service/autofill/SaveInfo$Builder;", "", ApiSince=27)>]
member this.SetValidator : Android.Service.Autofill.IValidator -> Android.Service.Autofill.SaveInfo.Builder
參數
- validator
- IValidator
這是由 Android 系統提供的實作。 這個值不可能為零值。
傳回
這個建築商。 這個值不可能為零值。
- 屬性
備註
設定一個物件用來驗證使用者輸入——如果輸入無效,則不會顯示自動填充存檔的 UI。
通常用來驗證信用卡號碼。
Validator validator = new RegexValidator(ccNumberId, Pattern.compile(""^\\d{16}$"))
import static android.service.autofill.Validators.and;
import static android.service.autofill.Validators.or;
Validator validator =
and(
new LuhnChecksumValidator(ccNumberId),
or(
new RegexValidator(ccNumberId, Pattern.compile("^\\d{16}$")),
new RegexValidator(ccNumberId, Pattern.compile("^108\\d{12}$"))
)
);
Validator validator =
and(
new LuhnChecksumValidator(ccNumberId),
new RegexValidator(ccNumberId, Pattern.compile(""^(\\d{16}|108\\d{12})$"))
);
import static android.service.autofill.Validators.and;
Validator validator =
and(
new RegexValidator(ccNumberId1, Pattern.compile("^\\d{4}$")),
new RegexValidator(ccNumberId2, Pattern.compile("^\\d{4}$")),
new RegexValidator(ccNumberId3, Pattern.compile("^\\d{4}$")),
new RegexValidator(ccNumberId4, Pattern.compile("^\\d{4}$"))
);
Android 參考資料。android.service.autofill.SaveInfo.Builder.setValidator
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。