Skip to content

Commit

Permalink
feat: Add email validation examples to Main class
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-logan committed Jul 11, 2024
1 parent 66d571c commit 1cac7b1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 28 deletions.
29 changes: 1 addition & 28 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,51 @@ public class Main {
}
```

### Validate

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

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

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

// Email validation with options: maxLength
ValidateEmailOptionsParams optionsMaxLength = new ValidateEmailOptionsParams();
optionsMaxLength.maxLength = 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: country specific
ValidateEmailOptionsParams optionsCountry = new ValidateEmailOptionsParams();
optionsCountry.country = "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: validDomains
ValidateEmailOptionsParams optionsValidDomains = new ValidateEmailOptionsParams();
optionsValidDomains.validDomains = 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: validDomainsList
ValidateEmailOptionsParams optionsValidDomainsList = new ValidateEmailOptionsParams();
optionsValidDomainsList.validDomainsList.add("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
}
}
```

### Validator

```java
Expand Down

0 comments on commit 1cac7b1

Please sign in to comment.