Skip to content

Instantly share code, notes, and snippets.

View bertybot's full-sized avatar

Bert B bertybot

View GitHub Profile
@bertybot
bertybot / phone_formatter.ts
Created November 18, 2024 20:49
Svelte Phone Formatter Action With Built In Validation
import type { ActionReturn } from "svelte/action";
import { AsYouType, isValidPhoneNumber } from 'libphonenumber-js/min';
interface Parameter {
countryCode: 'US'
}
export function phone_formatter(node: HTMLInputElement, params: Parameter = { countryCode: 'US' }): ActionReturn<Parameter> {
let value: string[] = []