Gathering detailed insights and metrics for @felte/validator-yup
Gathering detailed insights and metrics for @felte/validator-yup
Gathering detailed insights and metrics for @felte/validator-yup
Gathering detailed insights and metrics for @felte/validator-yup
An extensible form library for Svelte, Solid and React
npm install @felte/validator-yup
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (86.37%)
Astro (5.41%)
JavaScript (4.78%)
Svelte (1.75%)
CSS (1.7%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1,058 Stars
838 Commits
41 Forks
6 Watchers
23 Branches
29 Contributors
Updated on Jul 13, 2025
Latest Version
1.1.4
Package Id
@felte/validator-yup@1.1.4
Unpacked Size
15.10 kB
Size
4.43 kB
File Count
9
NPM Version
10.9.0
Node Version
22.10.0
Published on
Oct 29, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A package to help you handle validation with Yup in Felte.
1npm install --save @felte/validator-yup yup 2 3# Or, if you use yarn 4 5yarn add @felte/validator-yup yup
Call validator
with an object containing your Yup schema in the schema
property. The result of the call can be passed as an extender to Felte:
1import { validator } from '@felte/validator-yup'; 2import * as yup from 'yup'; 3 4const schema = yup.object({ 5 email: yup.string().email().required(), 6 password: yup.string().required(), 7}); 8 9const { form } = createForm({ 10 // ... 11 extend: validator({ schema }), // or `extend: [validator({ schema })],` 12 // ... 13});
OR use the validateSchema
function directly in the validate
option of createForm
. (No need to extend Felte).
1import { validateSchema } from '@felte/validator-yup'; 2import * as yup from 'yup'; 3 4const schema = yup.object({ 5 email: yup.string().email().required(), 6 password: yup.string().required(), 7}); 8 9const { form } = createForm({ 10 // ... 11 validate: validateSchema(schema), 12 // ... 13});
Unlike yup
, by default this validator does not cast values. If you wish to have this behaviour you may set the castValues
property to true
on the validator's configuration:
1const { form } = createForm({ 2 //... 3 extend: validator({ schema, castValues: true }), 4 //... 5});
NOTE: yup
throws if your schema fails to cast, we do not catch this errors so make sure your schema handles this appropriately to prevent your app from crashing. For example, lets assume we have a text
input that should be cast to an integer. yup
's number
rule would throw an error if a string is set so, in order to prevent your app from crashing, a custom rule would be needed:
1const schema = yup.object({ 2 shouldBeNumber: yup 3 .mixed() 4 .test('number', 'Must be a number', value => !isNaN(value)) 5 .transform(value => parseInt(value, 10)), 6});
Optionally, you can tell this package to assign the results of your validations to your warnings
store by setting the level
property of the validator function to warning
. It's error
by default:
1import { validator } from '@felte/validator-yup'; 2import * as yup from 'yup'; 3 4const validateSchema = yup.object({ 5 email: yup.string().email().required(), 6 password: yup.string().required(), 7}); 8 9// We only warn if the user has already started typing a value 10const warnSchema = yup.object({ 11 password: yup 12 .string() 13 .test('is-secure', 'password is not secure', (value) => 14 value ? value.length > 8 : true 15 ), 16}); 17 18const { form } = createForm({ 19 // ... 20 extend: [ 21 validator({ schema }), 22 validator({ schema: warnSchema, level: 'warning' }), 23 ], 24 // ... 25});
Yup allows you to infer the type of your schema using yup.InferType
. This can be used so you don't need to create a type for your form's data:
1import * as yup from 'yup'; 2 3const schema = yup.object({ 4 email: yup.string().email().required(), 5 password: yup.string().required(), 6}); 7 8const { form } = createForm<yup.InferType<typeof schema>>(/* ... */);
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 6/30 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
37 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More