How to use the is_js.within function in is_js

To help you get started, we’ve selected a few is_js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenBazaar / openbazaar-desktop / js / models / ServerConfig.js View on Github external
if (!valid) {
          addError('torProxy', app.polyglot.t('serverConfigModelErrors.invalidTorProxy'));
        }
      }

      if (!attrs.torPassword && this.isTorPwRequired()) {
        addError('torPassword', app.polyglot.t('serverConfigModelErrors.provideValue'));
      }
    }

    if (!attrs.builtIn) {
      if (attrs.port === undefined || attrs.port === '') {
        addError('port', app.polyglot.t('serverConfigModelErrors.provideValue'));
      } else if (!is.number(attrs.port)) {
        addError('port', app.polyglot.t('serverConfigModelErrors.providePortAsNumber'));
      } else if (!is.within(attrs.port, -1, 65536)) {
        addError('port', app.polyglot.t('serverConfigModelErrors.provideValidPortRange'));
      }
    } else {
      if (is.existy(attrs.port) && attrs.port !== this.defaults().port) {
        // For now, not allowing the port to be changed on built in servers,
        // since there is currently no way to set the port as an option
        // on the command line, the local bundled server will always be started
        // with the default port.
        addError('port', `On a built-in server, the port can only be ${this.defaults().port}.`);
      }
    }

    if (Object.keys(errObj).length) return errObj;

    return undefined;
  }
github OpenBazaar / openbazaar-desktop / js / models / ServerConfig.js View on Github external
if (attrs.useTor) {
      if (!attrs.torProxy) {
        addError('torProxy', app.polyglot.t('serverConfigModelErrors.provideValue'));
      } else if (typeof attrs.torProxy !== 'string') {
        addError('torProxy', 'Please provide the tor proxy configuration as a string.');
      } else {
        let valid = true;
        const split = attrs.torProxy.split(':');

        if (split.length !== 2) {
          valid = false;
        } else {
          if (!is.ip(split[0]) && split[0] !== 'localhost') {
            valid = false;
          } else if (!is.within(parseInt(split[1], 10), -1, 65536)) {
            valid = false;
          }
        }

        if (!valid) {
          addError('torProxy', app.polyglot.t('serverConfigModelErrors.invalidTorProxy'));
        }
      }

      if (!attrs.torPassword && this.isTorPwRequired()) {
        addError('torPassword', app.polyglot.t('serverConfigModelErrors.provideValue'));
      }
    }

    if (!attrs.builtIn) {
      if (attrs.port === undefined || attrs.port === '') {
github OpenBazaar / OpenBazaar-Client / js / models / serverConfigMd.js View on Github external
this._addError(err, 'rest_api_port', 'Please provide a number between 0 and 65535.');
      }
    }

    if (!is.number(attrs.api_socket_port)) {
      this._addError(err, 'api_socket_port', 'Please provide a number.');
    } else {
      if (!is.within(attrs.api_socket_port, -1, 65536)) {
        this._addError(err, 'api_socket_port', 'Please provide a number between 0 and 65535.');
      }
    }    

    if (!is.number(attrs.heartbeat_socket_port)) {
      this._addError(err, 'heartbeat_socket_port', 'Please provide a number.');
    } else {
      if (!is.within(attrs.heartbeat_socket_port, -1, 65536)) {
        this._addError(err, 'heartbeat_socket_port', 'Please provide a number between 0 and 65535.');
      }
    }    

    if (!this.isLocalServer()) {
      if (!is.existy(attrs.username) || is.empty(attrs.username)) {
        this._addError(err, 'username', 'Please provide a value.');
      }

      if (!is.existy(attrs.password) || is.empty(attrs.password)) {
        this._addError(err, 'password', 'Please provide a value.');
      }
    }

    if (Object.keys(err).length > 0) {
      return err;
github OpenBazaar / OpenBazaar-Client / js / models / serverConfigMd.js View on Github external
}
      }
    }

    if (!is.existy(attrs.server_ip) || is.empty(attrs.server_ip)) {
      this._addError(err, 'server_ip', 'Please provide a value.');
    } else {
      if (!is.ip(attrs.server_ip)) {
        this._addError(err, 'server_ip', 'This does not appear to be a valid IP address.');
      }      
    }

    if (!is.number(attrs.rest_api_port)) {
      this._addError(err, 'rest_api_port', 'Please provide a number.');
    } else {
      if (!is.within(attrs.rest_api_port, -1, 65536)) {
        this._addError(err, 'rest_api_port', 'Please provide a number between 0 and 65535.');
      }
    }

    if (!is.number(attrs.api_socket_port)) {
      this._addError(err, 'api_socket_port', 'Please provide a number.');
    } else {
      if (!is.within(attrs.api_socket_port, -1, 65536)) {
        this._addError(err, 'api_socket_port', 'Please provide a number between 0 and 65535.');
      }
    }    

    if (!is.number(attrs.heartbeat_socket_port)) {
      this._addError(err, 'heartbeat_socket_port', 'Please provide a number.');
    } else {
      if (!is.within(attrs.heartbeat_socket_port, -1, 65536)) {
github OpenBazaar / OpenBazaar-Client / js / models / serverConfigMd.js View on Github external
this._addError(err, 'server_ip', 'This does not appear to be a valid IP address.');
      }      
    }

    if (!is.number(attrs.rest_api_port)) {
      this._addError(err, 'rest_api_port', 'Please provide a number.');
    } else {
      if (!is.within(attrs.rest_api_port, -1, 65536)) {
        this._addError(err, 'rest_api_port', 'Please provide a number between 0 and 65535.');
      }
    }

    if (!is.number(attrs.api_socket_port)) {
      this._addError(err, 'api_socket_port', 'Please provide a number.');
    } else {
      if (!is.within(attrs.api_socket_port, -1, 65536)) {
        this._addError(err, 'api_socket_port', 'Please provide a number between 0 and 65535.');
      }
    }    

    if (!is.number(attrs.heartbeat_socket_port)) {
      this._addError(err, 'heartbeat_socket_port', 'Please provide a number.');
    } else {
      if (!is.within(attrs.heartbeat_socket_port, -1, 65536)) {
        this._addError(err, 'heartbeat_socket_port', 'Please provide a number between 0 and 65535.');
      }
    }    

    if (!this.isLocalServer()) {
      if (!is.existy(attrs.username) || is.empty(attrs.username)) {
        this._addError(err, 'username', 'Please provide a value.');
      }