barsa 0f6bae840f feat: add eligibility check flow with form, OTP, and success steps
- Implemented FormStep component for user input (name, email, address).
- Created OtpStep component for OTP verification.
- Developed SuccessStep component to display success messages based on account creation.
- Introduced eligibility-check.store for managing state throughout the eligibility check process.
- Added commitlint configuration for standardized commit messages.
- Configured knip for workspace management and project structure.
2026-01-15 11:28:25 +09:00

62 lines
1.4 KiB
TypeScript

/**
* Toolkit - Type Guards
*
* Type guard utilities for runtime type checking.
*/
/**
* Check if value is a non-null object
*/
export function isObject(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
/**
* Check if value is a non-empty array
*/
export function isNonEmptyArray<T>(value: unknown): value is [T, ...T[]] {
return Array.isArray(value) && value.length > 0;
}
/**
* Check if value is a string
*/
export function isString(value: unknown): value is string {
return typeof value === "string";
}
/**
* Check if value is a number
*/
export function isNumber(value: unknown): value is number {
return typeof value === "number" && !Number.isNaN(value);
}
/**
* Check if value is a boolean
*/
export function isBoolean(value: unknown): value is boolean {
return typeof value === "boolean";
}
/**
* Check if value is null or undefined
*/
export function isNullish(value: unknown): value is null | undefined {
return value === null || value === undefined;
}
/**
* Check if value is defined (not null or undefined)
*/
export function isDefined<T>(value: T | null | undefined): value is T {
return value !== null && value !== undefined;
}
/**
* Filter out null/undefined values from array
*/
export function filterDefined<T>(arr: (T | null | undefined)[]): T[] {
return arr.filter(isDefined);
}