Accounts/Methods/Validation

Accounts/Methods/Validation

Source:

Methods for Account Validation Methods for validating account username, email and password. Methods are exported globally in the LoginFormValidation object and they are also registered as Meteor methods. Call the methods using Meteor.call() or LoginFormValidation.method.

Examples

LoginFormValidation.password(password, { validationLevel: "exists" })
Meteor.call("accounts/validation/email", newEmail, false, (result, error))

Methods

(static) accounts/validation/email(email, optional) → {Boolean|Object}

Validates both required and optional email addresses.

Source:
Examples
LoginFormValidation.email(emailAddress)
Meteor.call("accounts/validation/email", newEmail, false, callbackFunction())
Parameters:
Name Type Description
email String

Email address to validate

optional Boolean

If set to true, validation will pass if email is blank

Returns:

Returns true if valid; Returns an error object if invalid

Type
Boolean | Object

(static) accounts/validation/password(password, options) → {Boolean|Object}

Passwords may be validated 2 ways.

  1. "exists" (options.validationLevel = "exists") - Password must not be blank. Thats is the only rule. Used to validate a sign in.
  2. undefined (options.validationLevel = undefined) - Password must meet the lenght and other criteria to validate. Used for validating a new sign up.

Source:
Example
LoginFormValidation.password(pword, { validationLevel: "exists" })
Parameters:
Name Type Description
password String

Password to validate

options Object

Options to apply to the password validator

Properties
Name Type Description
validationLevel String

"exists" | undefined (default)

Returns:

true if valid | Error object otherwise: {error: String, reason: String}

Type
Boolean | Object

(static) accounts/validation/username(username) → {Boolean|Object}

Determines if a username meets the minimum requirement of 3 characters

Source:
Parameters:
Name Type Description
username String

Username to validate

Returns:

true if valid, error object if invalid

Type
Boolean | Object