New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@gen2code/core

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gen2code/core

Core utilities, types, and configurations for the Gen2Code framework

Source
npmnpm
Version
3.0.0
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

@gen2code/core

Core utilities, types, and configurations for the Gen2Code framework.

Installation

npm install @gen2code/core
# or
yarn add @gen2code/core
# or
pnpm add @gen2code/core

Usage

Types

import type { User, Team, ApiResponse } from '@gen2code/core';

// Use the types in your application
const user: User = {
  // ... user data
};

Validation

import { validateEmail, validatePassword, validateSchema } from '@gen2code/core';

// Email validation
const isValidEmail = validateEmail('user@example.com');

// Password validation with strength scoring
const passwordResult = validatePassword('MySecurePassword123!');
console.log(passwordResult.strength); // 0-5 strength score

// Schema validation with Zod
import { z } from 'zod';
const userSchema = z.object({
  email: z.string().email(),
  name: z.string().min(1),
});

const result = validateSchema(userSchema, userData);
if (result.isValid) {
  console.log('Valid user data:', result.data);
}

Pre-built Schemas

import { 
  createUserRegistrationSchema,
  createUserLoginSchema,
  createTeamSchema 
} from '@gen2code/core';

// Use pre-built schemas for common operations
const registrationSchema = createUserRegistrationSchema();
const loginSchema = createUserLoginSchema();
const teamSchema = createTeamSchema();

Features

Types

  • Authentication: AuthUser, AuthSession, Permission, Role
  • User Management: User, UserProfile, UserSettings, UserRole
  • Team Management: Team, TeamMember, TeamInvitation, TeamRole
  • API: ApiResponse, ApiError, PaginatedResponse, RequestConfig
  • Common: Utility types for TypeScript development

Validation

  • Email Validation: RFC-compliant email validation with domain filtering
  • Password Validation: Strength scoring with customizable requirements
  • URL Validation: Protocol and domain validation
  • Phone Validation: International phone number validation
  • Schema Validation: Zod-based schema validation with error handling
  • Field Validation: Generic field validation utilities

Constants

  • Validation Patterns: Pre-defined regex patterns
  • Error Codes: Standardized validation error codes
  • Constraints: Default validation constraints

API Reference

Validation Functions

validateEmail(email: string): boolean

Validates email addresses according to RFC standards.

validatePassword(password: string, options?: PasswordValidationOptions): PasswordValidationResult

Validates password strength with customizable requirements.

validateUrl(url: string, options?: UrlValidationOptions): boolean

Validates URL format and protocols.

validatePhone(phone: string, options?: PhoneValidationOptions): boolean

Validates international phone numbers.

validateSchema<T>(schema: ZodSchema<T>, data: unknown): SchemaValidationResult<T>

Validates data against Zod schemas with detailed error reporting.

Schema Builders

createEmailSchema(options?: EmailSchemaOptions): ZodSchema

Creates a Zod schema for email validation with domain filtering.

createPasswordSchema(options?: PasswordSchemaOptions): ZodSchema

Creates a Zod schema for password validation with strength requirements.

createUserRegistrationSchema(): ZodSchema

Pre-built schema for user registration forms.

createUserLoginSchema(): ZodSchema

Pre-built schema for user login forms.

TypeScript Support

This package is written in TypeScript and provides comprehensive type definitions for all exports. All validation functions include proper type inference and error handling.

Tests

This package includes a minimal smoke test to ensure the build exposes expected exports.

  • Location: __tests__/smoke.test.js (imports dist/index.js and asserts key exports)
  • Runner: Jest (invoked by pnpm test via Turbo after pnpm build)
  • No tests scenario: The script uses jest --passWithNoTests, so CI passes if no test files exist.

Skip options

  • Local: CORE_SKIP_SMOKE_TEST=1 pnpm --filter @gen2code/core test
  • CI manual run: In Actions → Release → Run workflow, set input Skip @gen2code/core smoke test to true
  • CI default: Define repository variable SKIP_CORE_SMOKE_TEST=1 (Settings → Secrets and variables → Actions → Variables)
  • Remove tests: Delete/rename __tests__/smoke.test.js to rely on --passWithNoTests

Re-enable by removing the env/variable or restoring the test file.

Contributing

This package is part of the Gen2Code framework. Please refer to the main repository for contribution guidelines.

License

MIT

Keywords

gen2code

FAQs

Package last updated on 24 Sep 2025

Did you know?

Socket

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.

Install

Related posts