UNPKG

is-valid-phone-tr

Version:

Validator for Turkish mobile phone numbers

70 lines (44 loc) โ€ข 1.29 kB
# ๐Ÿ“ฑ is-valid-phone-tr Validate Turkish mobile phone numbers with ease. This package checks whether a given string is a valid Turkish GSM number. Supports common formats like `+90`, `05`, or just `5`. --- ## ๐Ÿ“ฆ Installation ### Using npm ```bash npm install is-valid-phone-tr ``` ### Using yarn ```bash yarn add is-valid-phone-tr ``` --- ## ๐Ÿš€ Usage ```js const isValidPhone = require("is-valid-phone-tr"); console.log(isValidPhone("05551234567")); // true console.log(isValidPhone("+905551234567")); // true console.log(isValidPhone("5551234567")); // true console.log(isValidPhone("123456")); // false ``` --- ## โš™๏ธ Options There are no configuration options. | Format Supported | Example | |---------------------|-----------------| | With country code | `+905551234567` | | With zero prefix | `05551234567` | | Without prefix | `5551234567` | | With spaces/dashes | `0555 123 45 67` / `0555-123-4567` | --- ## ๐Ÿงพ How It Works It uses a regular expression to validate Turkish GSM numbers (`5xx` area codes) and allows optional country prefix (`+90`, `0`). --- ## ๐Ÿงช Run Test ```bash node test.js ``` --- ## ๐Ÿชช License ``` MIT ```