@exuus/rwanda-phone-utils
Version:
A package to validate and format rwandan phone numbers
15 lines (13 loc) • 409 B
text/typescript
import constants from "../constants";
import { TelcoType } from "interface";
export default (
phone: string,
phoneTelco?: { label: string; value: TelcoType }
): { isValid: boolean; message: string } => {
if (phone.length < constants.shortLength)
return { isValid: false, message: constants.errors.short };
return {
isValid: !!phoneTelco?.label,
message: constants.errors.invalid,
};
};