天天看點

Android 表單驗證開源架構 saripaar Android Saripaar

下載下傳位址:

https://github.com/ragunathjawahar/android-saripaar

Android 表單驗證開源架構 saripaar Android Saripaar

சரிபார் - sari-paar (tamil for "to check", "verify" or "validate")

android saripaar is a simple, yet powerful rule-based ui validation library for android. it is the simplestvalidation library available for android.

declarative style validation powered by annotations.

extensible

synchronous and asynchronous validations, you don't have to worry about threading.

works with stock android widgets, no custom view dependencies.

quick to setup, just download the jar and include it in your <code>libs</code> project

folder.

isolates validation logic using rules.

compatible with other annotation frameworks such as androidannotations, roboguice,

etc.,

step 1 - annotate your widgets using saripaar

annotations

the annotations are self-explanatory. the <code>order</code> attribute is mandatory and specifies the order in which the

validations will be performed by the library.

step 2 - instantiate a new validator

you will need a <code>validator</code> and a <code>validationlistener</code> for

receiving callbacks on validation events.

step 3 - implement a validationlistener

<code>onvalidationsucceeded()</code> - called when all your views pass all validations.

<code>onvalidationfailed(view, rule&lt;?&gt;)</code> - called when a <code>rule</code> fails,

you receive the <code>view</code> along with the <code>rule</code> that

failed.

step 4 - validate

the <code>validator.validate()</code> call runs the validations and returns the result via appropriate callbacks on the <code>validationlistener</code>.

you can run validations on a background <code>asynctask</code> by calling the<code>validator.validateasync()</code> method.

please visit the wiki for a complete guide on android saripaar.

繼續閱讀