-
-
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.
feat: Add email validation examples to Main class
- Loading branch information
1 parent
66d571c
commit 1cac7b1
Showing
2 changed files
with
46 additions
and
28 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 |
---|---|---|
|
@@ -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 | ||
|