barsa 9941250cb5 refactor: streamline authentication workflows and remove legacy services
- Replace SignupWorkflowService and GetStartedWorkflowService with new coordinator services for improved modularity and clarity.
- Update auth controller to utilize the new GetStartedCoordinator.
- Refactor account status handling in the GetStartedForm component to leverage XState for state management.
- Introduce new hooks for managing the get-started flow, enhancing the overall user experience.
- Remove deprecated services and clean up related imports to maintain code hygiene.
2026-02-24 14:37:23 +09:00

25 lines
795 B
TypeScript

/**
* WHMCS Coercion Utilities (domain-internal)
*/
/**
* Coerce boolean-like values from WHMCS into actual booleans.
*
* Handles all shapes that WHMCS returns for boolean fields:
* - boolean → pass-through
* - number → 1 is true, everything else false
* - string → "1", "true", "yes", "on" are true (case-insensitive)
* - null / undefined → false
*/
export function coerceBoolean(value: boolean | number | string | null | undefined): boolean {
if (typeof value === "boolean") return value;
if (typeof value === "number") return value === 1;
if (typeof value === "string") {
const normalized = value.trim().toLowerCase();
return (
normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on"
);
}
return false;
}