1.0.0-rc.9 • Published 1 year ago
@exobase/use-validation v1.0.0-rc.9
@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
)
1.0.0-rc.9
1 year ago
1.0.0-rc.8
1 year ago
1.0.0-rc.7
1 year ago
1.0.0-rc.6
1 year ago
1.0.0-rc.5
2 years ago
1.0.0-rc.4
2 years ago
1.0.0-rc.3
2 years ago
1.0.0-rc.2
2 years ago