@exobase/use-validation
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-rc.9 • Public • Published

@exobase/use-validation

Provides hooks

Install

Yarn

yarn add @exobase/use-validation

Usage

If you're writing Exobase endpoints in Typescript you'll want to import the Props type.

import { compose } from 'radash'
import type { Props } from '@exobase/core'
import { useJsonArgs } from '@exobase/use-validation'
import { useLambda } from '@exobase/use-lambda'

type Args = {
  username: string
  password: string
}

const createAccount = async ({ args }: Props) => {
  // await db.users.add({
  //   username: args.username,
  //   password: args.password
  // })
}

const STRONG =
  /^(?=.*[A-Z].*[A-Z])(?=.*[!@#$&*])(?=.*[0-9].*[0-9])(?=.*[a-z].*[a-z].*[a-z]).{8}$/

export default compose(
  useLambda(),
  useJsonArgs(yup => ({
    username: yup.string().required(),
    password: yup
      .string()
      .matches(STRONG, { message: 'Password is too weak' })
      .required()
  })),
  createAccount
)

Readme

Keywords

none

Package Sidebar

Install

npm i @exobase/use-validation

Weekly Downloads

23

Version

1.0.0-rc.9

License

MIT

Unpacked Size

26.1 kB

Total Files

33

Last publish

Collaborators

  • rayepps