1.1.0
Minor Feature Improvement with Email Validations
With this version now you can use email validations to validate emails inside objects and string emails
Email Validators (Available with v1.1.0)
-
validateEmail Check given email address is valid..
-
Parameters
- email Email Address (EmailBasic type which is coming with this package)
Assume we have this email:
test@test.comYou can use below mentod to validate this email address
const validateSingleEmail = validateEmail('test@test.com')
-
-
EmailBasic type
from this custom basic type, you can validate basic email on development -
getEmail Check given email address is valid.
-
Parameters
- email Email Address (EmailBasic type which is coming with this package)
Assume we have this email:
test@test.comYou can use below mentod to validate this email address
const validateSingleEmail = validateEmail('test@test.com')
if email is valid, email will be returned. otherwise error exception will get returned.
-
-
validateEmailObject In Same way you can use this method which will return the entire object, if the email address is valid
-
Parameters
- obj Original Object
- path key path
You can use below mentod to validate object email
try { return validateEmailObject(userData, 'contact.email') } catch (ex) { return ex }
if email is valid, email will be returned. otherwise error exception will get returned.
-
-
autoValidateEmail Validate an object if the object contains key which contains word 'email'
-
Parameters
- obj Original Object
Lets say you have an object which needs to be validated if the object has any key value with key contains word 'email'. Then you can use this method.
Lets say you have below mentioned object
const userDataError: User = { name: 'heshan', contact: { email: 'test@#.c', address: 'Malmö', }, }
So this object has an invalid email address. So this will return Error.
try { return autoValidateEmail(userData) } catch (ex) { return ex }
if email is valid, email will be returned. otherwise error exception will get returned.
Error: INVALID_EMAIL
-