Skip to content

Getting Started

Welcome to medhira-rn-typescript-hooks — typed React Native validation hooks for forms, selects, and checkboxes.

Installation

npm install medhira-rn-typescript-hooks medhira-react-typescript-hooks react react-native
# Expo
npx expo install medhira-rn-typescript-hooks medhira-react-typescript-hooks

Hooks Overview

Hook Purpose
useValidateForm Text/number input validation
useValidateSelect Single or multiple select validation
useValidateCheckBox Checkbox validation

Quick Start

import { TextInput } from 'react-native';
import { useValidateForm } from 'medhira-rn-typescript-hooks';

const EmailField = () => {
  const form = useValidateForm({
    type: 'string',
    label: 'Email',
    isRequired: true,
    keyboard: 'email-address',
    validationPattern: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
  });

  return (
    <TextInput
      value={form.value ?? ''}
      onChangeText={form.valueChangeHandler}
      onFocus={form.valueFocusHandler}
      onBlur={form.valueBlurHandler}
    />
  );
};

Architecture

See the Architecture page for flow diagrams and package boundaries.

Requirements

License

MIT