Android库用于验证值

时间:2017-09-19 07:44:20

标签: java android validation saripaar

我正在使用名为 Android Saripaar v2

的验证库

link => https://github.com/ragunathjawahar/android-saripaar

它有一些像这样的功能

    @NotEmpty // this line does the magic
    @BindView(R.id.saveTextButton)
    TextView saveTextButton;

//请注意@BindView来自Butterknife

它工作正常,但我只能用它来验证ui元素,而不是简单的值,比如

boolean isUserPhotoSetted; // this should be true

我目前采用的方法是添加一个不同的块,只使用if语句处理布尔验证。

我相信这样的事情是可能的。

@ShouldBeTrue
boolean isUserPhotoSetted;

@MatchValue(true)
boolean isUserPhotoSetted;

以下链接中的相同内容。 https://github.com/ragunathjawahar/android-saripaar/issues/200

是否有任何库可以做这样的事情?

0 个答案:

没有答案