Skip to content

Commit

Permalink
refactor: code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
brenoepics committed Jul 20, 2024
1 parent 3721128 commit 6aac4b0
Show file tree
Hide file tree
Showing 45 changed files with 2,254 additions and 2,257 deletions.
14 changes: 7 additions & 7 deletions docs/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ Step 2. Add the dependency
```java
// You can import the class or use the full path

import io.github.multiform_validator.CnpjValidator;
import io.github.multiform_validator.identity.CnpjValidator;

public class Main {
public static void main(String[] args) {
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
}
public static void main(String[] args) {
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
}
}
```
32 changes: 16 additions & 16 deletions docs/content/classes/CnpjValidator.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ a `String` as a parameter and returns a `boolean` value.
```java
// You can import the class or use the full path

import io.github.multiform_validator.CnpjValidator;
import io.github.multiform_validator.identity.CnpjValidator;

public class Main {
public static void main(String[] args) {
System.out.println(cnpjIsTrue()); // true
System.out.println(cnpjIsFalse()); // false
}

public static boolean cnpjIsTrue() {
String cnpjTrue = "69.807.668/0001-41";
return CnpjValidator.cnpjIsValid(cnpjTrue);
}

public static boolean cnpjIsFalse() {
String cnpjFalse = "61.807.661/0001-48";
return CnpjValidator.cnpjIsValid(cnpjFalse);
}
public static void main(String[] args) {
System.out.println(cnpjIsTrue()); // true
System.out.println(cnpjIsFalse()); // false
}

public static boolean cnpjIsTrue() {
String cnpjTrue = "69.807.668/0001-41";
return CnpjValidator.cnpjIsValid(cnpjTrue);
}

public static boolean cnpjIsFalse() {
String cnpjFalse = "61.807.661/0001-48";
return CnpjValidator.cnpjIsValid(cnpjFalse);
}
}
```

Expand All @@ -33,4 +33,4 @@ public class Main {
- [FileValidator](https://multiform-validator.github.io/java/classes/FileValidator)
- [Utils](https://multiform-validator.github.io/java/classes/Utils)
- [Validate](https://multiform-validator.github.io/java/classes/Validate)
- [Validator](https://multiform-validator.github.io/java/classes/Validator)
- [Validator](https://multiform-validator.github.io/java/classes/Validator)
16 changes: 8 additions & 8 deletions docs/content/classes/CpfValidator.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ a `String` as a parameter and returns a `boolean` value.
```java
// You can also import the method as static or use the full path

import static io.github.multiform_validator.CpfValidator.cpfIsValid;
import static io.github.multiform_validator.identity.CpfValidator.cpfIsValid;

public class Main {
public static void main(String[] args) {
String cpfTrue = "123.456.789-09";
String cpfFalse = "123.456.789-10";
System.out.println(cpfIsValid(cpfTrue)); // true
System.out.println(cpfIsValid(cpfFalse)); // false
}
public static void main(String[] args) {
String cpfTrue = "123.456.789-09";
String cpfFalse = "123.456.789-10";
System.out.println(cpfIsValid(cpfTrue)); // true
System.out.println(cpfIsValid(cpfFalse)); // false
}
}
```

Expand All @@ -25,4 +25,4 @@ public class Main {
- [FileValidator](https://multiform-validator.github.io/java/classes/FileValidator)
- [Utils](https://multiform-validator.github.io/java/classes/Utils)
- [Validate](https://multiform-validator.github.io/java/classes/Validate)
- [Validator](https://multiform-validator.github.io/java/classes/Validator)
- [Validator](https://multiform-validator.github.io/java/classes/Validator)
38 changes: 19 additions & 19 deletions docs/content/classes/CreditCardValidator.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@ and `identifyCreditCard`.
### isCreditCardValid

```java
import io.github.multiform_validator.CreditCardValidator;
import io.github.multiform_validator.identity.CreditCardValidator;

public class Main {
public static void main(String[] args) {
valid();
invalid();
}
private static void valid() {
System.out.println(CreditCardValidator.isCreditCardValid("4532 8770 0040 4166")); // true
}
private static void invalid() {
System.out.println(CreditCardValidator.isCreditCardValid("4532 8770 0040 4167")); // false
}
public static void main(String[] args) {
valid();
invalid();
}

private static void valid() {
System.out.println(CreditCardValidator.isCreditCardValid("4532 8770 0040 4166")); // true
}

private static void invalid() {
System.out.println(CreditCardValidator.isCreditCardValid("4532 8770 0040 4167")); // false
}
}
```

### identifyCreditCard

```java
import io.github.multiform_validator.CreditCardValidator;
import io.github.multiform_validator.identity.CreditCardValidator;

public class Main {
public static void main(String[] args) {
String creditCard = "4532 8770 0040 4166";
System.out.println(CreditCardValidator.identifyCreditCard(creditCard)); // Visa
}
public static void main(String[] args) {
String creditCard = "4532 8770 0040 4166";
System.out.println(CreditCardValidator.identifyCreditCard(creditCard)); // Visa
}
}
```

Expand All @@ -44,4 +44,4 @@ public class Main {
- [FileValidator](https://multiform-validator.github.io/java/classes/FileValidator)
- [Utils](https://multiform-validator.github.io/java/classes/Utils)
- [Validate](https://multiform-validator.github.io/java/classes/Validate)
- [Validator](https://multiform-validator.github.io/java/classes/Validator)
- [Validator](https://multiform-validator.github.io/java/classes/Validator)
24 changes: 12 additions & 12 deletions docs/content/classes/Utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ methods:
### getOnlyEmail

```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, null)); // [email protected]

String msg2 = "Example two [email protected] and [email protected]";
// With options
Utils.GetOnlyEmailOptionsParams options = new Utils.GetOnlyEmailOptionsParams();
options.setMultiple(true);
System.out.println(Utils.getOnlyEmailWithOptions(msg2, options)); // [[email protected], [email protected]]
}
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, null)); // [email protected]

String msg2 = "Example two [email protected] and [email protected]";
// With options
Utils.OnlyEmailParams options = new Utils.OnlyEmailParams();
options.setMultiple(true);
System.out.println(Utils.getOnlyEmailWithOptions(msg2, options)); // [[email protected], [email protected]]
}
}
```

Expand All @@ -36,4 +36,4 @@ public class Main {
- [CreditCardValidator](https://multiform-validator.github.io/java/classes/CreditCardValidator)
- [FileValidator](https://multiform-validator.github.io/java/classes/FileValidator)
- [Validate](https://multiform-validator.github.io/java/classes/Validate)
- [Validator](https://multiform-validator.github.io/java/classes/Validator)
- [Validator](https://multiform-validator.github.io/java/classes/Validator)
67 changes: 33 additions & 34 deletions docs/content/classes/Validate.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,48 @@ The `Validate` class is a utility class with some methods to validate data. It h
### validateEmail

```java
import io.github.multiform_validator.Validate;
import io.github.multiform_validator.Validate.ValidateEmailOptionsParams;
import io.github.multiform_validator.format.EmailValidator;

import java.util.Collections;

public class Main {
public static void main(String[] args) {
validateEmailExample();
}
public static void main(String[] args) {
validateEmailExample();
}

public static void validateEmailExample() {
// IMPORTANT: validDomains can not be used with validDomainsList, you can use only one of them
public static void validateEmailExample() {
// IMPORTANT: validDomains can not be used with validDomainsList, you can use only one of them

// Basic email validation
boolean isValid = Validate.validateEmail("[email protected]");
System.out.println("Is valid: " + isValid); // Expected: true
// Basic email validation
boolean isValid = EmailValidator.validateEmail("[email protected]");
System.out.println("Is valid: " + isValid); // Expected: true

// Email validation with options: maxLength
ValidateEmailOptionsParams optionsMaxLength = new ValidateEmailOptionsParams();
optionsMaxLength.setMaxLength(10); // Setting max length to 10, which should fail for longer emails
boolean isValidMaxLength = Validate.validateEmail("[email protected]", optionsMaxLength);
System.out.println("Is valid with maxLength: " + isValidMaxLength); // Expected: false
// Email validation with options: maxLength
EmailParams optionsMaxLength = new EmailValidator.EmailParams();
optionsMaxLength.setMaxLength(10); // Setting max length to 10, which should fail for longer emails
boolean isValidMaxLength = EmailValidator.validateEmail("[email protected]", optionsMaxLength);
System.out.println("Is valid with maxLength: " + isValidMaxLength); // Expected: false

// Email validation with options: country specific
ValidateEmailOptionsParams optionsCountry = new ValidateEmailOptionsParams();
optionsCountry.setCountry("us"); // Expecting an email from the US
boolean isNotValidCountry = Validate.validateEmail("[email protected]", optionsCountry);
boolean isValidCountry = Validate.validateEmail("[email protected]", optionsCountry);
System.out.println("Is not valid with country: " + isNotValidCountry); // Expected: false
System.out.println("Is valid with country: " + isValidCountry); // Expected: true
// Email validation with options: country specific
EmailParams optionsCountry = new EmailParams();
optionsCountry.setCountry("us"); // Expecting an email from the US
boolean isNotValidCountry = EmailValidator.validateEmail("[email protected]", optionsCountry);
boolean isValidCountry = EmailValidator.validateEmail("[email protected]", optionsCountry);
System.out.println("Is not valid with country: " + isNotValidCountry); // Expected: false
System.out.println("Is valid with country: " + isValidCountry); // Expected: true

// Email validation with options: validDomains
ValidateEmailOptionsParams optionsValidDomains = new ValidateEmailOptionsParams();
optionsValidDomains.setValidDomains(true); // Only allow certain domains (implementation specific)
boolean isValidValidDomains = Validate.validateEmail("[email protected]", optionsValidDomains);
System.out.println("Is valid with validDomains: " + isValidValidDomains); // Expected: true
// Email validation with options: validDomains
EmailParams optionsValidDomains = new EmailParams();
optionsValidDomains.setValidDomains(true); // Only allow certain domains (implementation specific)
boolean isValidValidDomains = EmailValidator.validateEmail("[email protected]", optionsValidDomains);
System.out.println("Is valid with validDomains: " + isValidValidDomains); // Expected: true

// Email validation with options: validDomainsList
ValidateEmailOptionsParams optionsValidDomainsList = new ValidateEmailOptionsParams();
optionsValidDomainsList.setValidDomainsList(Collections.singletonList("specificdomain.com")); // Adding a specific domain to the list
boolean isValidValidDomainsList = Validate.validateEmail("[email protected]", optionsValidDomainsList);
System.out.println("Is valid with validDomainsList: " + isValidValidDomainsList); // Expected: true
}
// Email validation with options: validDomainsList
EmailValidator.EmailParams optionsValidDomainsList = new EmailValidator.EmailParams();
optionsValidDomainsList.setValidDomainsList(Collections.singletonList("specificdomain.com")); // Adding a specific domain to the list
boolean isValidValidDomainsList = EmailValidator.validateEmail("[email protected]", optionsValidDomainsList);
System.out.println("Is valid with validDomainsList: " + isValidValidDomainsList); // Expected: true
}
}
```

Expand All @@ -76,4 +75,4 @@ public class Main {
- [CreditCardValidator](https://multiform-validator.github.io/java/classes/CreditCardValidator)
- [FileValidator](https://multiform-validator.github.io/java/classes/FileValidator)
- [Utils](https://multiform-validator.github.io/java/classes/Utils)
- [Validator](https://multiform-validator.github.io/java/classes/Validator)
- [Validator](https://multiform-validator.github.io/java/classes/Validator)
23 changes: 1 addition & 22 deletions docs/content/classes/Validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,27 +160,6 @@ public class Main {
}
```

### isNumber

```java
import static io.github.multiform_validator.Validator.isNumber;

public class Main {
public static void main(String[] args) {
valid();
invalid();
}

private static void valid() {
System.out.println(isNumber("123")); // true
}

private static void invalid() {
System.out.println(isNumber("123a")); // false
}
}
```

### isPort

```java
Expand Down Expand Up @@ -263,4 +242,4 @@ public class Main {
- [CreditCardValidator](https://multiform-validator.github.io/java/classes/CreditCardValidator)
- [FileValidator](https://multiform-validator.github.io/java/classes/FileValidator)
- [Utils](https://multiform-validator.github.io/java/classes/Utils)
- [Validate](https://multiform-validator.github.io/java/classes/Validate)
- [Validate](https://multiform-validator.github.io/java/classes/Validate)
Loading

0 comments on commit 6aac4b0

Please sign in to comment.