
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
valix-validator
Advanced tools
Valix-validator helps you validate data in JavaScript and TypeScript with easy-to-use, reusable schemas.
Valix-validator is a lightweight, type-safe package that helps you validate data in JavaScript and TypeScript with easy-to-use, reusable schemas.
npm i valix-validator
import v from 'valix-validator';
// Define a schema
const userSchema = v.object({
username: v.string().minLength(3).maxLength(20),
email: v.string().email(),
age: v.number().min(18).integer(),
isActive: v.boolean()
});
// Type is inferred from schema
type User = v.infer<typeof userSchema>;
// Validate data
try {
const validatedUser = userSchema.parse({
username: 'john_doe',
email: 'john@example.com',
age: 25,
isActive: true
});
// validatedUser is typed as User
console.log(validatedUser);
} catch (error) {
console.error('Validation error:', error);
}
// Safe parsing (doesn't throw)
const result = userSchema.safeParse({
username: 'jo', // too short
email: 'not-an-email',
age: 17.5,
isActive: true
});
if (!result.success) {
console.log('Invalid data:', result.error);
} else {
console.log('Valid data:', result.value);
}
v.string() - Validates stringsv.number() - Validates numbersv.boolean() - Validates booleansv.date() - Validates Date objectsv.array() - Validates arraysv.object() - Validates objectsv.union() - Validates union typesv.literal() - Validates literal valuesv.tuple() - Validates tuplesv.record() - Validates records (objects with specific key/value types)v.any() - Accepts any value.minLength(n) - String must be at least n characters.maxLength(n) - String must not exceed n characters.pattern(regex) - String must match the regex pattern.email() - String must be a valid email.url() - String must be a valid URL.uuid() - String must be a valid UUID.min(n) - Number must be at least n.max(n) - Number must not exceed n.integer() - Number must be an integer.positive() - Number must be positive.negative() - Number must be negative.min(date) - Date must be after the specified date.max(date) - Date must be before the specified date.minLength(n) - Array must have at least n items.maxLength(n) - Array must not exceed n items.strict() - Object must not have extra properties.optional() - Makes the value optional (value | undefined).nullable() - Makes the value nullable (value | null)MIT
FAQs
Valix-validator helps you validate data in JavaScript and TypeScript with easy-to-use, reusable schemas.
We found that valix-validator 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.