Gathering detailed insights and metrics for @teamteanpm2024/officiis-sint-dolorum
Gathering detailed insights and metrics for @teamteanpm2024/officiis-sint-dolorum
npm install @teamteanpm2024/officiis-sint-dolorum
Typescript
Module System
Node Version
NPM Version
50.8
Supply Chain
93.5
Quality
80.3
Maintenance
100
Vulnerability
100
License
Cumulative downloads
Total Downloads
Last day
0%
0
Compared to previous day
Last week
0%
0
Compared to previous week
Last month
0%
0
Compared to previous month
Last year
0%
0
Compared to previous year
37
Performant, flexible and extensible forms with easy to use validation.
npm install @teamteanpm2024/officiis-sint-dolorum
type Options = {
mode: 'async' | 'sync',
raw?: boolean
}
resolver(schema: object, schemaOptions?: object, resolverOptions: Options)
type | Required | Description | |
---|---|---|---|
schema | object | ✓ | validation schema |
schemaOptions | object | validation library schema options | |
resolverOptions | object | resolver options, async is the default mode |
Dead simple Object schema validation.
1import { useForm } from 'react-hook-form'; 2import { yupResolver } from '@teamteanpm2024/officiis-sint-dolorum/yup'; 3import * as yup from 'yup'; 4 5const schema = yup 6 .object() 7 .shape({ 8 name: yup.string().required(), 9 age: yup.number().required(), 10 }) 11 .required(); 12 13const App = () => { 14 const { register, handleSubmit } = useForm({ 15 resolver: yupResolver(schema), 16 }); 17 18 return ( 19 <form onSubmit={handleSubmit((d) => console.log(d))}> 20 <input {...register('name')} /> 21 <input type="number" {...register('age')} /> 22 <input type="submit" /> 23 </form> 24 ); 25};
TypeScript-first schema validation with static type inference
⚠️ Example below uses the
valueAsNumber
, which requiresreact-hook-form
v6.12.0 (released Nov 28, 2020) or later.
1import { useForm } from 'react-hook-form'; 2import { zodResolver } from '@teamteanpm2024/officiis-sint-dolorum/zod'; 3import * as z from 'zod'; 4 5const schema = z.object({ 6 name: z.string().min(1, { message: 'Required' }), 7 age: z.number().min(10), 8}); 9 10const App = () => { 11 const { 12 register, 13 handleSubmit, 14 formState: { errors }, 15 } = useForm({ 16 resolver: zodResolver(schema), 17 }); 18 19 return ( 20 <form onSubmit={handleSubmit((d) => console.log(d))}> 21 <input {...register('name')} /> 22 {errors.name?.message && <p>{errors.name?.message}</p>} 23 <input type="number" {...register('age', { valueAsNumber: true })} /> 24 {errors.age?.message && <p>{errors.age?.message}</p>} 25 <input type="submit" /> 26 </form> 27 ); 28};
A simple and composable way to validate data in JavaScript (or TypeScript).
1import { useForm } from 'react-hook-form'; 2import { superstructResolver } from '@teamteanpm2024/officiis-sint-dolorum/superstruct'; 3import { object, string, number } from 'superstruct'; 4 5const schema = object({ 6 name: string(), 7 age: number(), 8}); 9 10const App = () => { 11 const { register, handleSubmit } = useForm({ 12 resolver: superstructResolver(schema), 13 }); 14 15 return ( 16 <form onSubmit={handleSubmit((d) => console.log(d))}> 17 <input {...register('name')} /> 18 <input type="number" {...register('age', { valueAsNumber: true })} /> 19 <input type="submit" /> 20 </form> 21 ); 22};
The most powerful data validation library for JS.
1import { useForm } from 'react-hook-form'; 2import { joiResolver } from '@teamteanpm2024/officiis-sint-dolorum/joi'; 3import Joi from 'joi'; 4 5const schema = Joi.object({ 6 name: Joi.string().required(), 7 age: Joi.number().required(), 8}); 9 10const App = () => { 11 const { register, handleSubmit } = useForm({ 12 resolver: joiResolver(schema), 13 }); 14 15 return ( 16 <form onSubmit={handleSubmit((d) => console.log(d))}> 17 <input {...register('name')} /> 18 <input type="number" {...register('age')} /> 19 <input type="submit" /> 20 </form> 21 ); 22};
Vest 🦺 Declarative Validation Testing.
1import { useForm } from 'react-hook-form'; 2import { vestResolver } from '@teamteanpm2024/officiis-sint-dolorum/vest'; 3import { create, test, enforce } from 'vest'; 4 5const validationSuite = create((data = {}) => { 6 test('username', 'Username is required', () => { 7 enforce(data.username).isNotEmpty(); 8 }); 9 10 test('password', 'Password is required', () => { 11 enforce(data.password).isNotEmpty(); 12 }); 13}); 14 15const App = () => { 16 const { register, handleSubmit, errors } = useForm({ 17 resolver: vestResolver(validationSuite), 18 }); 19 20 return ( 21 <form onSubmit={handleSubmit((data) => console.log(data))}> 22 <input {...register('username')} /> 23 <input type="password" {...register('password')} /> 24 <input type="submit" /> 25 </form> 26 ); 27};
Decorator-based property validation for classes.
⚠️ Remember to add these options to your
tsconfig.json
!
"strictPropertyInitialization": false,
"experimentalDecorators": true
1import { useForm } from 'react-hook-form'; 2import { classValidatorResolver } from '@teamteanpm2024/officiis-sint-dolorum/class-validator'; 3import { Length, Min, IsEmail } from 'class-validator'; 4 5class User { 6 @Length(2, 30) 7 username: string; 8 9 @IsEmail() 10 email: string; 11} 12 13const resolver = classValidatorResolver(User); 14 15const App = () => { 16 const { 17 register, 18 handleSubmit, 19 formState: { errors }, 20 } = useForm<User>({ resolver }); 21 22 return ( 23 <form onSubmit={handleSubmit((data) => console.log(data))}> 24 <input type="text" {...register('username')} /> 25 {errors.username && <span>{errors.username.message}</span>} 26 <input type="text" {...register('email')} /> 27 {errors.email && <span>{errors.email.message}</span>} 28 <input type="submit" value="Submit" /> 29 </form> 30 ); 31};
Validate your data with powerful decoders.
1import React from 'react'; 2import { useForm } from 'react-hook-form'; 3import { ioTsResolver } from '@teamteanpm2024/officiis-sint-dolorum/io-ts'; 4import t from 'io-ts'; 5// you don't have to use io-ts-types, but it's very useful 6import tt from 'io-ts-types'; 7 8const schema = t.type({ 9 username: t.string, 10 age: tt.NumberFromString, 11}); 12 13const App = () => { 14 const { register, handleSubmit } = useForm({ 15 resolver: ioTsResolver(schema), 16 }); 17 18 return ( 19 <form onSubmit={handleSubmit((d) => console.log(d))}> 20 <input {...register('username')} /> 21 <input type="number" {...register('age')} /> 22 <input type="submit" /> 23 </form> 24 ); 25}; 26 27export default App;
A small, simple, and fast JS validator
1import { useForm } from 'react-hook-form'; 2import { nopeResolver } from '@teamteanpm2024/officiis-sint-dolorum/nope'; 3import Nope from 'nope-validator'; 4 5const schema = Nope.object().shape({ 6 name: Nope.string().required(), 7 age: Nope.number().required(), 8}); 9 10const App = () => { 11 const { register, handleSubmit } = useForm({ 12 resolver: nopeResolver(schema), 13 }); 14 15 return ( 16 <form onSubmit={handleSubmit((d) => console.log(d))}> 17 <input {...register('name')} /> 18 <input type="number" {...register('age')} /> 19 <input type="submit" /> 20 </form> 21 ); 22};
TypeScript-first schema validation with static type inference
1import { useForm } from 'react-hook-form'; 2import { computedTypesResolver } from '@teamteanpm2024/officiis-sint-dolorum/computed-types'; 3import Schema, { number, string } from 'computed-types'; 4 5const schema = Schema({ 6 username: string.min(1).error('username field is required'), 7 age: number, 8}); 9 10const App = () => { 11 const { 12 register, 13 handleSubmit, 14 formState: { errors }, 15 } = useForm({ 16 resolver: computedTypesResolver(schema), 17 }); 18 19 return ( 20 <form onSubmit={handleSubmit((d) => console.log(d))}> 21 <input {...register('name')} /> 22 {errors.name?.message && <p>{errors.name?.message}</p>} 23 <input type="number" {...register('age', { valueAsNumber: true })} /> 24 {errors.age?.message && <p>{errors.age?.message}</p>} 25 <input type="submit" /> 26 </form> 27 ); 28};
Static and runtime type assertion library with no dependencies
1import { useForm } from 'react-hook-form'; 2import { typanionResolver } from '@teamteanpm2024/officiis-sint-dolorum/typanion'; 3import * as t from 'typanion'; 4 5const isUser = t.isObject({ 6 username: t.applyCascade(t.isString(), [t.hasMinLength(1)]), 7 age: t.applyCascade(t.isNumber(), [ 8 t.isInteger(), 9 t.isInInclusiveRange(1, 100), 10 ]), 11}); 12 13const App = () => { 14 const { 15 register, 16 handleSubmit, 17 formState: { errors }, 18 } = useForm({ 19 resolver: typanionResolver(isUser), 20 }); 21 22 return ( 23 <form onSubmit={handleSubmit((d) => console.log(d))}> 24 <input {...register('name')} /> 25 {errors.name?.message && <p>{errors.name?.message}</p>} 26 <input type="number" {...register('age')} /> 27 {errors.age?.message && <p>{errors.age?.message}</p>} 28 <input type="submit" /> 29 </form> 30 ); 31};
The fastest JSON validator for Node.js and browser
1import { useForm } from 'react-hook-form'; 2import { ajvResolver } from '@teamteanpm2024/officiis-sint-dolorum/ajv'; 3 4// must use `minLength: 1` to implement required field 5const schema = { 6 type: 'object', 7 properties: { 8 username: { 9 type: 'string', 10 minLength: 1, 11 errorMessage: { minLength: 'username field is required' }, 12 }, 13 password: { 14 type: 'string', 15 minLength: 1, 16 errorMessage: { minLength: 'password field is required' }, 17 }, 18 }, 19 required: ['username', 'password'], 20 additionalProperties: false, 21}; 22 23const App = () => { 24 const { 25 register, 26 handleSubmit, 27 formState: { errors }, 28 } = useForm({ 29 resolver: ajvResolver(schema), 30 }); 31 32 return ( 33 <form onSubmit={handleSubmit((data) => console.log(data))}> 34 <input {...register('username')} /> 35 {errors.username && <span>{errors.username.message}</span>} 36 <input {...register('password')} /> 37 {errors.password && <span>{errors.password.message}</span>} 38 <button type="submit">submit</button> 39 </form> 40 ); 41};
JSON Schema Type Builder with Static Type Resolution for TypeScript
1import { useForm } from 'react-hook-form'; 2import { typeboxResolver } from '@teamteanpm2024/officiis-sint-dolorum/typebox'; 3import { Type } from '@sinclair/typebox'; 4 5const schema = Type.Object({ 6 username: Type.String({ minLength: 1 }), 7 password: Type.String({ minLength: 1 }), 8}); 9 10const App = () => { 11 const { register, handleSubmit } = useForm({ 12 resolver: typeboxResolver(schema), 13 }); 14 15 return ( 16 <form onSubmit={handleSubmit((d) => console.log(d))}> 17 <input {...register('username')} /> 18 <input type="password" {...register('password')} /> 19 <input type="submit" /> 20 </form> 21 ); 22};
TypeScript's 1:1 validator, optimized from editor to runtime
1import { useForm } from 'react-hook-form'; 2import { arktypeResolver } from '@teamteanpm2024/officiis-sint-dolorum/arktype'; 3import { type } from 'arktype'; 4 5const schema = type({ 6 username: 'string>1', 7 password: 'string>1', 8}); 9 10const App = () => { 11 const { register, handleSubmit } = useForm({ 12 resolver: arktypeResolver(schema), 13 }); 14 15 return ( 16 <form onSubmit={handleSubmit((d) => console.log(d))}> 17 <input {...register('username')} /> 18 <input type="password" {...register('password')} /> 19 <input type="submit" /> 20 </form> 21 ); 22};
The modular and type safe schema library for validating structural data
1import { useForm } from 'react-hook-form'; 2import { valibotResolver } from '@teamteanpm2024/officiis-sint-dolorum/valibot'; 3import { object, string, minLength, endsWith } from 'valibot'; 4 5const schema = object({ 6 username: string('username is required', [ 7 minLength(3, 'Needs to be at least 3 characters'), 8 endsWith('cool', 'Needs to end with `cool`'), 9 ]), 10 password: string('password is required'), 11}); 12 13const App = () => { 14 const { register, handleSubmit } = useForm({ 15 resolver: valibotResolver(schema), 16 }); 17 18 return ( 19 <form onSubmit={handleSubmit((d) => console.log(d))}> 20 <input {...register('username')} /> 21 <input type="password" {...register('password')} /> 22 <input type="submit" /> 23 </form> 24 ); 25};
Thanks goes to all our backers! [Become a backer].
Thanks go to these kind and lovely sponsors!
Thanks goes to these wonderful people! [Become a contributor].
No vulnerabilities found.
No security vulnerabilities found.