项目作者: Techie-Qabila

项目描述 :
Android form validation library
高级语言: Java
项目地址: git://github.com/Techie-Qabila/DroidValidatorLight.git
创建时间: 2016-02-15T22:43:08Z
项目社区:https://github.com/Techie-Qabila/DroidValidatorLight

开源协议:

下载


DroidValidatorLight

This library is heavily inspired by AwesomeValidation but with no external dependencies. It makes it very light weight

Setup

Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url "https://jitpack.io" }
  5. }
  6. }

Step 2. Add the dependency

  1. compile 'com.github.mahmed8003:DroidValidatorLight:${VERSION}'

Usage Examples

  1. Form form = new Form(this);
  2. form.enablePerFieldErrorMessageDisplay(); // If you want per field validation
  3. // For simple scenarios
  4. form.check(editText, RegexTemplate.NOT_EMPTY_PATTERN, "Must not be empty");
  5. form.check(editText, RegexTemplate.EMAIL_PATTERN, "Must be an Email");
  6. form.checkLength(editText, Range.equalOrLess(12), "Text length must be less or equal to 12");
  7. form.checkValue(editText2, Range.equalOrMore(23), "Entered value must be greater equal than 23");
  8. if(form.validate()) {
  9. Toast.makeText(this, "Success", Toast.LENGTH_LONG).show();
  10. }

You can remove validate from form as well, You can make your own validators by extending Validator class.

Happy Validation, Thanks

License

  1. Copyright (C) 2018 Muhammad Ahmed
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.