不要怂,就是干,撸起袖子干!

Commit 602110f0 by Sushant

docs: improve ValidationErrorItem docs

1 parent 28c6574d
Showing with 50 additions and 3 deletions
...@@ -37,7 +37,7 @@ exports.SequelizeScopeError = SequelizeScopeError; ...@@ -37,7 +37,7 @@ exports.SequelizeScopeError = SequelizeScopeError;
* @param {string} message Error message * @param {string} message Error message
* @param {Array} [errors] Array of ValidationErrorItem objects describing the validation errors * @param {Array} [errors] Array of ValidationErrorItem objects describing the validation errors
* *
* @property errors An array of ValidationErrorItems * @property errors {ValidationErrorItems[]}
*/ */
class ValidationError extends BaseError { class ValidationError extends BaseError {
constructor(message, errors) { constructor(message, errors) {
...@@ -234,20 +234,65 @@ exports.UnknownConstraintError = UnknownConstraintError; ...@@ -234,20 +234,65 @@ exports.UnknownConstraintError = UnknownConstraintError;
* @param {Object} [validatorKey] a validation "key", used for identification * @param {Object} [validatorKey] a validation "key", used for identification
* @param {String} [fnName] property name of the BUILT-IN validator function that caused the validation error (e.g. "in" or "len"), if applicable * @param {String} [fnName] property name of the BUILT-IN validator function that caused the validation error (e.g. "in" or "len"), if applicable
* @param {String} [fnArgs] parameters used with the BUILT-IN validator function, if applicable * @param {String} [fnArgs] parameters used with the BUILT-IN validator function, if applicable
*
* @param {string} value The value that generated the error
*/ */
class ValidationErrorItem { class ValidationErrorItem {
constructor(message, type, path, value, inst, validatorKey, fnName, fnArgs) { constructor(message, type, path, value, inst, validatorKey, fnName, fnArgs) {
/**
* An error message
*
* @type {String} message
*/
this.message = message || ''; this.message = message || '';
/**
* The type/origin of the validation error
*
* @type {String}
*/
this.type = null; this.type = null;
/**
* The field that triggered the validation error
*
* @type {String}
*/
this.path = path || null; this.path = path || null;
/**
* The value that generated the error
*
* @type {String}
*/
this.value = value !== undefined ? value : null; this.value = value !== undefined ? value : null;
this.origin = null; this.origin = null;
/**
* The DAO instance that caused the validation error
*
* @type {Model}
*/
this.instance = inst || null; this.instance = inst || null;
/**
* A validation "key", used for identification
*
* @type {String}
*/
this.validatorKey = validatorKey || null; this.validatorKey = validatorKey || null;
/**
* Property name of the BUILT-IN validator function that caused the validation error (e.g. "in" or "len"), if applicable
*
* @type {String}
*/
this.validatorName = fnName || null; this.validatorName = fnName || null;
/**
* Parameters used with the BUILT-IN validator function, if applicable
*
* @type {String}
*/
this.validatorArgs = fnArgs || []; this.validatorArgs = fnArgs || [];
if (type) { if (type) {
...@@ -278,6 +323,8 @@ class ValidationErrorItem { ...@@ -278,6 +323,8 @@ class ValidationErrorItem {
* defaults to "." (fullstop). only used and validated if useTypeAsNS is TRUE. * defaults to "." (fullstop). only used and validated if useTypeAsNS is TRUE.
* @throws {Error} thrown if NSSeparator is found to be invalid. * @throws {Error} thrown if NSSeparator is found to be invalid.
* @return {String} * @return {String}
*
* @private
*/ */
getValidatorKey(useTypeAsNS, NSSeparator) { getValidatorKey(useTypeAsNS, NSSeparator) {
const useTANS = typeof useTypeAsNS === 'undefined' ? true : !!useTypeAsNS; const useTANS = typeof useTypeAsNS === 'undefined' ? true : !!useTypeAsNS;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!