@exobase/use-validation
v1.0.0-rc.9
Published
Exobase request validation hooks
Downloads
18
Readme
@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
)