How to use the ow.string 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-provider-outlook / lib / get-emails.js View on Github external
module.exports = async (opts) => {
  const {
    browser,
    query
  } = opts

  ow(query, ow.string.nonEmpty.label('query'))

  let page

  try {
    const page = await browser.newPage()
    await page.goto('https://outlook.live.com/mail/inbox')
    await delay(1000)

    // search for an input query to narrow down email results
    // TODO: don't require a search query
    await page.waitFor('input[aria-label=Search]', { visible: true })
    await delay(2000)

    let attempts = 0
    do {
      await page.focus('input[aria-label=Search]')
github liaisonjs / liaison / packages / mongodb-store / src / mongodb-store.js View on Github external
constructor(connectionString) {
    ow(connectionString, ow.string.url);

    super();

    this._connectionString = connectionString;
  }
github BoostIO / BoostNote.next / src / lib / db / store.ts View on Github external
createStorage,
      removeStorage,
      renameStorage,
      createFolder,
      removeFolder,
      createNote,
      updateNote,
      trashNote,
      untrashNote,
      purgeNote
    }
  }
}

const storageDataPredicate = schema({
  id: ow.string,
  name: ow.string
})

export const {
  StoreProvider: DbProvider,
  useStore: useDb
} = createStoreContext(createDbStoreCreator(localLiteStorage, 'idb'))

export function getStorageDataList(
  liteStorage: LiteStorage
): NoteStorageData[] | null {
  const serializedStorageDataList = liteStorage.getItem(storageDataListKey)

  try {
    const parsedStorageDataList = JSON.parse(serializedStorageDataList || '[]')
    if (!Array.isArray(parsedStorageDataList))
github ridi / react-viewer / src / validators / ComicValidator.ts View on Github external
[ComicSettingProperties.BINDING_TYPE]: BindingTypeOptional,
  [ComicSettingProperties.LAZY_LOAD]: ow.optional.any(ow.boolean, ow.number.not.negative),
});

export const ImageData = ow.object.partialShape({
  fileSize: notNegativeNumber,
  index: notNegativeNumber,
  path: ow.optional.string,
  uri: ow.optional.string,
  width: notNegativeNumberOptional,
  height: notNegativeNumberOptional,
});

export const ComicParsedData = ow.object.partialShape({
  images: ow.optional.array.ofType(ImageData),
  unzipPath: ow.string,
});
github transitive-bullshit / captcha-solver / packages / captcha-solver / index.js View on Github external
async getTaskResult (taskId, opts = { }) {
    ow(taskId, ow.string.nonEmpty)
    ow(opts, ow.object.plain)

    const {
      retries = 3,
      timeout = 30000,
      ...rest
    } = opts

    return pTimeout(pRetry(async () => {
      const result = await this._provider.getTaskResult(taskId)

      if (result.status !== 'ready') {
        throw new Error(`task is still processing (status "${result.status}")`)
      }

      return result
github hegemonic / jsdoc-baseline / lib / file-info.js View on Github external
constructor(parentPath, relativeChildPath) {
        ow(parentPath, ow.string);
        ow(relativeChildPath, ow.string);

        this.absolute = path.join(parentPath, relativeChildPath);
        this.parent = parentPath;
        this.relative = relativeChildPath;
    }
};
github transitive-bullshit / sms-number-verifier / index.js View on Github external
async getAuthCodes (opts) {
    const {
      retries = 3,
      minTimeout = 5000,
      maxTimeout = 20000,
      timestamp = this._timestamp,
      number,
      service,
      ...rest
    } = opts

    ow(number, ow.string.nonEmpty.label('number'))
    ow(service, ow.string.nonEmpty.label('service'))
    ow(opts, ow.object.plain.nonEmpty.label('opts'))

    let attempt = 0
    return pRetry(async () => {
      const messages = await this._provider.getMessages({ number, service, ...rest, attempt })

      const results = (messages || [])
        .filter((m) => m.service === service)
        .filter((m) => !timestamp || m.timestamp >= timestamp)
        .map((m) => m.code)

      if (!results.length) {
        ++attempt
        throw new Error(`waiting for SMS message for service \`${service}\` at number \`${number}\``)
      }
github transitive-bullshit / npm-es-modules / 1-naive / browser.js View on Github external
export default async (input) => {
  ow(input, ow.any(
    ow.string.nonEmpty.label('input'),
    ow.object.instanceOf(global.Image).label('input')
  ))

  const image = await loadImage(input)

  return {
    width: image.width,
    height: image.height
  }
}

ow

Function argument validation for humans

MIT
Latest version published 17 days ago

Package Health Score

80 / 100
Full package analysis