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

@bitkai/dynamic-fields

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bitkai/dynamic-fields

A TypeScript library for handling dynamic form fields with validation.

latest
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

Dynamic Fields

A TypeScript library for handling dynamic form fields with validation.

Installation

npm install @bitkai/dynamic-fields

Usage

For complete examples, check out the examples folder:

  • Form Schema Example - Shows how to define a complex form schema
  • Usage Example - Demonstrates validation and default values

Basic usage:

import { Field, validateField, getDefaultValue, InferFieldType } from '@bitkai/dynamic-fields';

// Define a field schema
const field = {
  type: 'text',
  key: 'name',
  label: 'Name',
  minLength: 2,
  maxLength: 50,
  optional: false
} as const satisfies Field;

// Infer the type of the field value
type FieldValue = InferFieldType<typeof field>; // string

// Get default value
const defaultValue = getDefaultValue(field); // returns ''

// Validate a value
try {
  const value: FieldValue = 'John';
  validateField(field, value);
  console.log('Valid!');
} catch (error) {
  console.error(error.message);
}

The InferFieldType helper provides automatic type inference for your field values based on the field definition. This ensures type safety when working with form values.

Field Types

The library supports the following field types:

  • text: Text input with optional length constraints
  • number: Numeric input
  • boolean: Boolean/checkbox input
  • array: Array of fields
  • group: Group of fields
  • select: Single selection from options
  • multiselect: Multiple selection from options
  • image: Image input
  • color: Color input
  • date: Date input
  • time: Time input

Contributing

  • Fork the repository
  • Create your feature branch (git checkout -b feature/amazing-feature)
  • Commit your changes (git commit -m 'Add some amazing feature')
  • Push to the branch (git push origin feature/amazing-feature)
  • Open a Pull Request

License

MIT

FAQs

Package last updated on 06 Apr 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