How to use the ow.object function in ow

To help you get started, we’ve selected a few ow 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 transitive-bullshit / puppeteer-email / packages / puppeteer-email / index.js View on Github external
async signin (user, opts = { }) {
    let browser
    try {
      browser = opts.browser || await puppeteer.launch(opts.puppeteer)

      ow(user, ow.object.plain.nonEmpty.label('user'))
      ow(user.password, ow.string.nonEmpty.label('user.password'))

      if (user.username) {
        ow(user.username, ow.string.nonEmpty.label('user.username'))
        user.email = `${user.username}@${this._provider.name}.com`
        ow(user.email, ow.string.nonEmpty.label('user.email'))
      } else if (user.email) {
        ow(user.email, ow.string.nonEmpty.label('user.email'))
        user.username = user.email.split('@')[0].trim()
        ow(user.username, ow.string.nonEmpty.label('user.username'))
      } else {
        throw new Error('missing required parameter "username" or "email"')
      }

      const session = await this._provider.signin(user, {
        browser,
github transitive-bullshit / puppeteer-lottie / index.js View on Github external
: output
  const frameType = (isJpg ? 'jpeg' : 'png')
  const isMultiFrame = isMp4 || /%d|%\d{2,3}d/.test(tempOutput)

  let lottieData = animationData

  if (animationPath) {
    if (animationData) {
      throw new Error('"animationData" and "path" are mutually exclusive')
    }

    ow(animationPath, ow.string.nonEmpty, 'path')

    lottieData = fs.readJsonSync(animationPath)
  } else if (animationData) {
    ow(animationData, ow.object.plain.nonEmpty, 'animationData')
  } else {
    throw new Error('Must pass either "animationData" or "path"')
  }

  const fps = ~~lottieData.fr
  const { w = 640, h = 480 } = lottieData
  const aR = w / h

  ow(fps, ow.number.integer.positive, 'animationData.fr')
  ow(w, ow.number.integer.positive, 'animationData.w')
  ow(h, ow.number.integer.positive, 'animationData.h')

  if (!(width && height)) {
    if (width) {
      height = width / aR
    } else if (height) {
github jsdoc / jsdoc / packages / jsdoc-task-runner / lib / task-runner.js View on Github external
addTasks(tasks) {
        ow(tasks, ow.any(ow.array, ow.object));
        this._addOrRemoveTasks(tasks, this.addTask, 'add');

        return this;
    }
github transitive-bullshit / sms-number-verifier / lib / provider-plivo.js View on Github external
constructor (opts = { }) {
    super()

    ow(opts, ow.object.plain.label('opts'))

    const authId = opts.authId || process.env.PLIVO_AUTH_ID
    const authToken = opts.authToken || process.env.PLIVO_AUTH_TOKEN

    ow(authId, ow.string.nonEmpty.label('plivo authId'))
    ow(authToken, ow.string.nonEmpty.label('plivo authToken'))

    this._messages = { }

    this._client = new plivo.Client(authId, authToken)

    this._server = new IncomingSMSServer({
      transform: (body) => {
        const message = {
          from: body.From,
          to: body.To,
github transitive-bullshit / captcha-solver / packages / captcha-solver / index.js View on Github external
constructor (provider, opts = { }) {
    this._provider = typeof provider === 'object'
      ? provider
      : providers.getProviderByName(provider, opts)
    ow(this._provider, ow.object.instanceOf(CaptchaSolverProvider))
    ow(opts, ow.object.plain)
  }
github berstend / puppeteer-extra / packages / puppeteer-extra-plugin-devtools / index.js View on Github external
getUrlForPage(page) {
    ow(page, ow.object.hasKeys('_target._targetInfo.targetId'))
    const pageId = page._target._targetInfo.targetId
    return super.getUrlForPageId(pageId)
  }
github wise-team / steem-wise-cli / src / config / Config.ts View on Github external
private static async loadFromFilesBasedOnPriority(
        command: commander.Command, prevConfig: Config,
    ): Promise {
        ow(command, ow.object.label("command"));
        ow(prevConfig, ow.object.label("prevConfig"));

        const configFiles: string [] = _.cloneDeep(StaticConfig.DEFAULT_CONFIG_FILE_PATHS);
        if (command.configFile) configFiles.unshift(command.configFile);

        const newConfig = await PrioritizedFileObjectLoader.loadFromFiles(prevConfig, configFiles, "config");
        const configLoadedFromFile: ConfigLoadedFromFile = {
            ...newConfig.loadedObject,
            configFilePath: path.resolve((newConfig.path ? newConfig.path : ".")),
        };
        return configLoadedFromFile;
    }
github berstend / puppeteer-extra / packages / puppeteer-extra-plugin-repl / lib / REPLSession.js View on Github external
constructor(opts) {
    ow(opts, ow.object.hasKeys('obj'))
    ow(opts.obj, ow.object.hasKeys('constructor'))

    this._obj = opts.obj
    this._meta = {
      type: typeof this._obj,
      name: this._obj.constructor.name,
      members:
        Object.getOwnPropertyNames(Object.getPrototypeOf(this._obj)) || []
    }
    this._completions = [].concat(this.extraMethods, this._meta.members)
  }

ow

Function argument validation for humans

MIT
Latest version published 2 months ago

Package Health Score

80 / 100
Full package analysis