-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7d767f
commit 90a1215
Showing
2 changed files
with
129 additions
and
40 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,35 +11,145 @@ follow the steps below to use the library in your project. | |
|
||
https://jitpack.io/#multiform-validator/java/ | ||
|
||
## Example of how to use | ||
## Available methods - JAVA (0.0.2)v | ||
|
||
- CnpjValidator | ||
- cnpjIsValid | ||
|
||
- CpfValidator | ||
- cpfIsValid | ||
|
||
CreditCardValidator | ||
- isCreditCardValid | ||
- identifyCreditCard | ||
|
||
- EmailValidator | ||
- isEmail | ||
|
||
- Utils | ||
- getOnlyEmail | ||
- getOnlyEmailWithOptions (options) | ||
- multiple (boolean) - default: false | ||
- cleanDomain (boolean) - default: false | ||
- repeatEmail (boolean) - default: false | ||
|
||
- Validator | ||
- isAscii | ||
- isCEP | ||
- isDate | ||
- isDecimal | ||
- isMACAddress | ||
- isNumber | ||
- isPort | ||
- isPostalCode | ||
- isTime | ||
|
||
|
||
## How to use | ||
|
||
### CnpjValidator | ||
```java | ||
import io.github.multiform_validator.Validator; | ||
import io.github.multiform_validator.EmailValidator; | ||
import io.github.multiform_validator.CpfValidator; | ||
import io.github.multiform_validator.CnpjValidator; | ||
import io.github.multiform_validator.Utils; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
System.out.println(EmailValidator.isEmail("[email protected]")); // true | ||
System.out.println(EmailValidator.isEmail("foo@bar")); // false | ||
String cnpjTrue = "69.807.668/0001-41"; | ||
String cnpjFalse = "61.807.661/0001-48"; | ||
System.out.println(CnpjValidator.cnpjIsValid(cnpjTrue)); // true | ||
System.out.println(CnpjValidator.cnpjIsValid(cnpjFalse)); // false | ||
} | ||
} | ||
``` | ||
|
||
### CpfValidator | ||
```java | ||
import io.github.multiform_validator.CpfValidator; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
String cpfTrue = "123.456.789-09"; | ||
String cpfFalse = "123.456.789-10"; | ||
System.out.println(CpfValidator.cpfIsValid(cpfTrue)); // true | ||
System.out.println(CpfValidator.cpfIsValid(cpfFalse)); // false | ||
} | ||
} | ||
``` | ||
|
||
System.out.println(CpfValidator.cpfIsValid("123.456.789-09")); // true | ||
System.out.println(CpfValidator.cpfIsValid("123.456.789-00")); // false | ||
|
||
System.out.println(CnpjValidator.cnpjIsValid("12.345.678/0001-09")); // true | ||
System.out.println(CnpjValidator.cnpjIsValid("12.345.678/0001-00")); // false | ||
### CreditCardValidator | ||
```java | ||
import io.github.multiform_validator.CreditCardValidator; | ||
|
||
System.out.println(Validator.isAscii("foo")); // true | ||
System.out.println(Validator.isAscii("foo©")); // false | ||
|
||
System.out.println(Utils.getOnlyEmail("This is an example [email protected] bla yes my friend loren ipsun")); // [email protected] | ||
System.out.println(Utils.getOnlyEmail("This is an example bla yes my friend loren ipsun")); // null | ||
public class Main { | ||
public static void main(String[] args) { | ||
String creditCard = "4532 8770 0040 4166"; | ||
System.out.println(CreditCardValidator.isCreditCardValid(creditCard)); // true | ||
System.out.println(CreditCardValidator.identifyCreditCard(creditCard)); // Visa | ||
} | ||
} | ||
``` | ||
|
||
### EmailValidator | ||
```java | ||
import static io.github.multiform_validator.EmailValidator.isEmail; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
String email = "[email protected]"; | ||
System.out.println(isEmail(email)); // true | ||
} | ||
} | ||
``` | ||
|
||
### Utils | ||
```java | ||
import io.github.multiform_validator.Utils; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
String msg1 = "This is a message example with [email protected] email to test"; | ||
System.out.println(Utils.getOnlyEmail(msg1)); // [email protected] | ||
|
||
String msg2 = "Example two [email protected] and [email protected]"; | ||
// With options | ||
Utils.GetOnlyEmailOptionsParams options = new Utils.GetOnlyEmailOptionsParams(); | ||
options.multiple = true; | ||
System.out.println(Utils.getOnlyEmail("This is an example [email protected] bla [email protected] yes yes", options)); // [[email protected], [email protected]] | ||
System.out.println(Utils.getOnlyEmailWithOptions(msg2, options)); // [[email protected], [email protected]] | ||
} | ||
} | ||
``` | ||
|
||
### Validator | ||
```java | ||
import io.github.multiform_validator.Validator; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
validMethods(); | ||
invalidMethods(); | ||
} | ||
|
||
public void validMethods () { | ||
System.out.println(Validator.isAscii("foo")); // true | ||
System.out.println(Validator.isCEP("12345-678")); // true | ||
System.out.println(Validator.isDate("2021-01-01")); // true | ||
System.out.println(Validator.isDecimal("1.5")); // true | ||
System.out.println(Validator.isMACAddress("00:00:00:00:00:00")); // true | ||
System.out.println(Validator.isNumber("123")); // true | ||
System.out.println(Validator.isPort("8080")); // true | ||
System.out.println(Validator.isPostalCode("12345-678")); // true | ||
System.out.println(Validator.isTime("12:00")); // true | ||
} | ||
|
||
public void invalidMethods () { | ||
System.out.println(Validator.isAscii("こんにちは")); // false | ||
System.out.println(Validator.isCEP("12345678")); // false | ||
System.out.println(Validator.isDate("2021-01-32")); // false | ||
System.out.println(Validator.isDecimal("1.5.5")); // false | ||
System.out.println(Validator.isMACAddress("00:00:00:00:00:00:00")); // false | ||
System.out.println(Validator.isNumber("123a")); // false | ||
System.out.println(Validator.isPort("8080a")); // false | ||
System.out.println(Validator.isPostalCode("12345678")); // false | ||
System.out.println(Validator.isTime("12:00:00")); // false | ||
} | ||
} | ||
``` | ||
|