![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Assert validator for TypeScript projects.
npm install vator
// ESM or TypeScript projects:
import { v, validate, buildSchema, is } from 'vator';
// CommonJS projects:
const { v, validate, buildSchema, is } = require('vator');
is
is a collection of shortcuts for comparing types of values.
The regular
if (value === undefined) {
...
}
can be replaced with more convenient
if (is.undefined(value)) {
...
}
Designed to be used in conditions, because it uses type guard
approach.
const maybeNumber = Math.random() > 0.5 ? 10 : null;
if (is.number(maybeNumber)) {
// TS will not complain, because maybeNumber is number already
console.log(maybeNumber + 10); // 20
} else {
console.log(maybeNumber === null); // true
}
Available is
validators:
is.undefined();
is.null();
is.nullable();
is.string();
is.number();
is.email();
is.phone();
Will validate that value
is a string type:
const value = 'some';
validate(value, v.string);
Will throw an error if value is not matching the type:
const value = 22;
validate(value, v.string);
Error:
Validation failed: value has type 'number', but 'string' type is required.
Will validate that value
is an object with described fields.
Also it's more convenient to use buildSchema
helper to get schema
and ResultType
.
Note
ReturnType
is an empty object, only refers to valid result type!.
// Let's pretend that 'value' is 'unknown' type
const value: unknown = {
name: 'some-name',
age: 100,
isOnline: false,
updatedAt: '2023-05-22T14:32:34.324Z',
unknownData: [2, 'foo', false]
cars: [
{
model: 'bmw',
year: 2017
},
{
model: 'audi',
year: null
}
]
};
const { schema, ResultType } = buildSchema({
name: v.string,
age: v.optional.number,
isOnline: v.maybe.boolean,
updatedAt: v.Date,
unknownData: v.unknown,
cars: v.array(v.object({
model: v.literal('bmw', 'audi'),
year: v.nullable.number
}))
});
validate(value, schema)
Also value
will then have valid types (because validate()
asserts them)
FAQs
Assert validator for TypeScript projects
We found that vator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.