Validator


Source link: https://github.com/nicolkill/Validator

Validator

Validator is a library that help to make validations easy, with the custom edit text or just the validator class.

Features

  • Easy implementation
  • Validation out of views

For more functions or bugs, create a issue.

Usage

Add gradle dependecy

dependencies {

compile 'com.nicolkill:validator:{
latest_release
}
' 
}
 

Step 1:

if you want use only validator

Example with created validator

Validator validator = new PhoneValidator();
 if (validator.isValid("123456789a")) {

  // some stuff 
}
 else {

  // another stuff 
}

Example with self maked validator

Validator validator = new Validator() {

  @Override
  public boolean isValid(String text) {

// check if text size is greater that 20

return text.length() > 20;
  
}
 
}
; if (validator.isValid("abcdefghijklmnopqrstuvwxyz")) {

  // some stuff 
}
 else {

  // another stuff 
}

If you want use the custom view

Step 1:

Add the following xml on your view:

<com.nicolkill.validator.views.ValidateTextInputLayout
  app:type_validator="email"
  app:text_error="@string/invalid_mail"
  android:id="@+id/edit1"
  android:layout_width="match_parent"
  android:layout_height="wrap_content">

<EditText

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="@string/mail"

android:text="[email protected]"/>  </com.nicolkill.validator.views.ValidateTextInputLayout>

or

<com.nicolkill.validator.views.ValidateEditText
  app:type_validator="name"
  app:text_error="@string/invalid_name"
  android:id="@+id/edit2"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:hint="@string/name" />

Step 2:

Get reference and set data:

ValidateTextInputLayout mValidateTextInputLayout = (ValidateTextInputLayout) findViewById(R.id.edit1);
 ValidateEditText mValidateEditText = (ValidateEditText) findViewById(R.id.edit2);

Step 3:

Check if the field is valid

adapter.setOnClickListener(new ClickListener<Option>() {

  @Override
  public void onItemSelected(View view, int position, Option element) {

if (mValidateTextInputLayout.isValid() && mValidateEditText.isValid()) {

 // some stuff

}
 else {

 // another stuff

}

  
}
 
}
);

Resources

RxTuples is a library to smooth RxJava usage by adding simple Tuple creation functions.

Custom preference view for preference screens on Android. Each social icon is selectable in the normal view. If the user clicks on the title, the dialog appears which is also clickable. Each social icon is programmed to open in the corresponding app or in the browser if the app isn't present. Including this library into your preference screen layout is very easy.

Simple Library to create RecyclerView Adapters and Viewholder in a snap.

Send any data to any Viewholder without creating custom RecyclerView Adapters.

Charter is a library to show graphics.

Simple library that helps creating a "Tap Bar" menu layout.

Card Menu View.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes