Package com.networknt.schema.format
Class EmailValidator
- java.lang.Object
-
- com.networknt.schema.BaseJsonValidator
-
- com.networknt.schema.format.EmailValidator
-
- All Implemented Interfaces:
JsonValidator,JsonSchemaWalker
public class EmailValidator extends BaseJsonValidator implements JsonValidator
Perform email validations.
Based on a script by Sandeep V. Tamhankar http://javascript.internet.com
This implementation is not guaranteed to catch all possible errors in an email address.
.- Since:
- Validator 1.4
- Version:
- $Revision$
-
-
Field Summary
-
Fields inherited from class com.networknt.schema.BaseJsonValidator
applyDefaultsStrategy, failFast, parentSchema, schemaNode, schemaPath, validationContext
-
Fields inherited from interface com.networknt.schema.JsonValidator
AT_ROOT
-
-
Constructor Summary
Constructors Constructor Description EmailValidator(String schemaPath, com.fasterxml.jackson.databind.JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext, String formatName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisValid(String email)Checks if a field has a valid e-mail address.protected booleanisValidDomain(String domain)Returns true if the domain component of an email address is valid.protected booleanisValidUser(String user)Returns true if the user component of an email address is valid.Set<ValidationMessage>validate(com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode rootNode, String at)Validate the given JsonNode, the given node is the child node of the root node at given data path.-
Methods inherited from class com.networknt.schema.BaseJsonValidator
buildValidationMessage, checkDiscriminatorMatch, debug, equals, fetchSubSchemaNode, getNodeFieldType, getParentSchema, getSchemaNode, getSchemaPath, getValidatorType, greaterThan, isPartOfOneOfMultipleType, lessThan, parseErrorCode, preloadJsonSchemas, registerAndMergeDiscriminator, validate, walk
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.networknt.schema.walk.JsonSchemaWalker
walk
-
Methods inherited from interface com.networknt.schema.JsonValidator
preloadJsonSchema, validate
-
-
-
-
Constructor Detail
-
EmailValidator
public EmailValidator(String schemaPath, com.fasterxml.jackson.databind.JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext, String formatName)
-
-
Method Detail
-
isValid
public boolean isValid(String email)
Checks if a field has a valid e-mail address.
- Parameters:
email- The value validation is being performed on. Anullvalue is considered invalid.- Returns:
- true if the email address is valid.
-
isValidDomain
protected boolean isValidDomain(String domain)
Returns true if the domain component of an email address is valid.- Parameters:
domain- being validated, may be in IDN format- Returns:
- true if the email address's domain is valid.
-
isValidUser
protected boolean isValidUser(String user)
Returns true if the user component of an email address is valid.- Parameters:
user- being validated- Returns:
- true if the user name is valid.
-
validate
public Set<ValidationMessage> validate(com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.JsonNode rootNode, String at)
Description copied from interface:JsonValidatorValidate the given JsonNode, the given node is the child node of the root node at given data path.- Specified by:
validatein interfaceJsonValidator- Parameters:
node- JsonNoderootNode- JsonNodeat- String- Returns:
- A list of ValidationMessage if there is any validation error, or an empty list if there is no error.
-
-