* Will extract arguments for the validator. * * @param {*} test The test case. * @param {string} validatorType One of known to Sequelize validators. * @param {string} field The field that is being validated. * * @private
(test, validatorType, field)
| 317 | * @private |
| 318 | */ |
| 319 | _extractValidatorArgs(test, validatorType, field) { |
| 320 | let validatorArgs = test.args || test; |
| 321 | const isLocalizedValidator = typeof validatorArgs !== 'string' && ['isAlpha', 'isAlphanumeric', 'isMobilePhone'].includes(validatorType); |
| 322 | |
| 323 | if (!Array.isArray(validatorArgs)) { |
| 324 | if (validatorType === 'isImmutable') { |
| 325 | validatorArgs = [validatorArgs, field, this.modelInstance]; |
| 326 | } else if (isLocalizedValidator || validatorType === 'isIP') { |
| 327 | validatorArgs = []; |
| 328 | } else { |
| 329 | validatorArgs = [validatorArgs]; |
| 330 | } |
| 331 | } else { |
| 332 | validatorArgs = validatorArgs.slice(0); |
| 333 | } |
| 334 | return validatorArgs; |
| 335 | } |
| 336 | |
| 337 | /** |
| 338 | * Will validate a single field against its schema definition (isnull). |
no outgoing calls
no test coverage detected