fjlValidatorReCaptcha

Created by elydelacruz on 6/10/16.
See:
To Do:
  • Request handlers should be separated out from inlined definitions

Members

static, constant BAD_REQUEST :string

static, constant INVALID_INPUT_RESPONSE :string

Properties:
Name Type Description
INVALID_INPUT_RESPONSE

static, constant INVALID_INPUT_SECRET :string

Properties:
Name Type Description
INVALID_INPUT_SECRET

static, constant MISSING_INPUT_RESPONSE :string

Properties:
Name Type Description
MISSING_INPUT_RESPONSE

static, constant MISSING_INPUT_SECRET :string

Properties:
Name Type Description
MISSING_INPUT_SECRET

static, constant UNKNOWN_ERROR :string

Properties:
Name Type Description
UNKNOWN_ERROR

Methods

static makeReCaptchaRequest$(options, value, resolve, reject) → {void}

Makes request to reCaptchaV2 service using passed in options and test value.
Parameters:
Name Type Description
options ReCaptchaValidatorOptions
value ReCaptchaTestValue
resolve function Resolve/success callback - Receives validation result object.
reject function Reject/failure callback - Receives validation result object and errorCodes array.
Returns:
void

static reCaptchaIOValidator(options, value) → {Promise.<ValidationResult>|Promise.<ValidationResult, Array.<String>>}

Curried version of `reCaptchaIOValidator$`.
Parameters:
Name Type Description
options ReCaptchaValidatorOptions
value ReCaptchaTestValue
Returns:
Promise.<ValidationResult> | Promise.<ValidationResult, Array.<String>>

static reCaptchaIOValidator$(options, value) → {Promise.<ValidationResult>|Promise.<ValidationResult, Array.<String>>}

Validates a test value against reCaptchaV2 backend service;
Parameters:
Name Type Description
options ReCaptchaValidatorOptions
value ReCaptchaTestValue
Returns:
Promise.<ValidationResult> | Promise.<ValidationResult, Array.<String>>

static reCaptchaValidator(options, value) → {Promise.<ValidationResult>|Promise.<ValidationResult, Array.<String>>}

Alias of `reCaptchaIOValidator`.
Parameters:
Name Type Description
options ReCaptchaValidatorOptions
value ReCaptchaTestValue
Returns:
Promise.<ValidationResult> | Promise.<ValidationResult, Array.<String>>

static reCaptchaValidator$(options, value, resolve, reject) → {void}

Validates a test value against google's reCaptchaV2 backend validation service;
Parameters:
Name Type Description
options ReCaptchaValidatorOptions
value ReCaptchaTestValue
resolve function Resolve/success callback - Receives validation result object.
reject function Reject/failure callback - Receives validation result object and errorCodes array.
Returns:
void

static reCaptchaValidatorV2(value, options) → {Promise.<ValidationResult>|Promise.<ValidationResult, Array.<String>>}

Same as `reCaptchaIOValidator` though with arguments flipped; Takes `value` parameter first and the `options` one second.
Parameters:
Name Type Description
value ReCaptchaTestValue
options ReCaptchaValidatorOptions
Returns:
Promise.<ValidationResult> | Promise.<ValidationResult, Array.<String>>

static toReCaptchaTestValue(incoming, outgoing=opt) → {ReCaptchaTestValue}

Normalizes value object to be tested by `reCaptchaValidator`.
Parameters:
Name Type Attributes Description
incoming Object Incoming 'un-normalized' test value object; E.g. `{secret: '', resonse: '', etc...}`
outgoing= <optional>
Optional. Outgoing object to apply enumerable prop getters and setters to.
Throws:
- If any of `secret`, `response`, or `remoteip` are passed in with values containing anything other than values of type String.
Type
Error
Returns:
ReCaptchaTestValue - - In the form of `{secret, response, remoteip}`.

static toReCaptchaValidatorOptions(options, outgoing=opt) → {ReCaptchaValidatorOptions}

Normalizes value object to be tested by `reCaptchaValidator`.
Parameters:
Name Type Attributes Description
options Object Incoming 'un-normalized' test value object; E.g. `{secret: '', resonse: '', etc...}`
outgoing= <optional>
Optional. Outgoing object to apply enumerable prop getters and setters to.
Throws:
- If any of the passed object's properties do not match expected types.
Type
Error
Returns:
ReCaptchaValidatorOptions - - `{requestOptions {Object}, messageTemplates {Object}}`.