npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

turkish-form-validator

v1.1.1

Published

Turkish form validation library

Downloads

44

Readme

Turkish Form Validator 🇹🇷

A comprehensive validation library for Turkish forms including TCKN, phone numbers, tax numbers, license plates, and IBAN validation.

📋 Features

  • TCKN Validation - Validate Turkish National Identification Numbers
  • Phone Number Validation - Validate Turkish mobile phone numbers with formatting
  • Tax Number Validation - Validate Turkish tax numbers with checksum
  • License Plate Validation - Validate Turkish vehicle license plates
  • IBAN Validation - Validate Turkish IBAN numbers
  • TypeScript Support - Full TypeScript definitions included
  • Zero Dependencies - Lightweight with no external dependencies

🚀 Installation

npm install turkish-form-validator

or

yarn add turkish-form-validator

📖 Usage

TCKN Validation

import { validateTCKN } from "turkish-form-validator";

const result = validateTCKN("12345678950");
if (result.isValid) {
  console.log("Valid TCKN");
} else {
  console.log(result.error);
}

Phone Number Validation

import { validateTurkishPhone } from "turkish-form-validator";

const result = validateTurkishPhone("0532 123 45 67");
if (result.valid) {
  console.log("Valid phone:", result.formatted); // +905321234567
} else {
  console.log(result.message);
}

Tax Number Validation

import { validateTaxNo } from "turkish-form-validator";

const result = validateTaxNo("1234567890");
if (result.valid) {
  console.log("Valid tax number:", result.formatted);
} else {
  console.log(result.message);
}

For corporate (Ltd./A.Ş.) taxpayers, tax numbers can start with 0. To support these scenarios, you can pass isCorporate: true as the second parameter:

const corporateResult = validateTaxNo("0000000005", { isCorporate: true });

License Plate Validation

import { validateTurkishPlate } from "turkish-form-validator";

const result = validateTurkishPlate("06 ABC 123");
if (result.valid) {
  console.log("Valid plate:", result.formatted);
  console.log("City:", result.cityName);
  console.log("Type:", result.plateType);
} else {
  console.log(result.message);
}

IBAN Validation

import { validateTurkishIBAN } from "turkish-form-validator";

const result = validateTurkishIBAN("TR330006100519786457841326");
if (result.valid) {
  console.log("Valid IBAN:", result.formatted);
  console.log("Bank:", result.bankName);
} else {
  console.log(result.message);
}

🎯 Framework Examples

React Example

import { useState } from "react";
import { validateTCKN } from "turkish-form-validator";

function TCKNInput() {
  const [error, setError] = useState<string>("");

  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    const result = validateTCKN(e.target.value);
    if (!result.isValid) {
      setError(result.error || "");
    } else {
      setError("");
    }
  };

  return (
    <div>
      <input type="text" onChange={handleChange} />
      {error && <span className="error">{error}</span>}
    </div>
  );
}

Vue 3 Example (Composition API)

<template>
  <div>
    <input v-model="phone" @input="validate" />
    <p v-if="error" class="error">{{ error }}</p>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { validateTurkishPhone } from "turkish-form-validator";

const phone = ref("");
const error = ref("");

const validate = () => {
  const result = validateTurkishPhone(phone.value);
  error.value = result.valid ? "" : result.message;
};
</script>

Angular Example

import { Component } from "@angular/core";
import { FormControl, Validators } from "@angular/forms";
import { validateTCKN } from "turkish-form-validator";

@Component({
  selector: "app-tckn-input",
  template: `
    <input [formControl]="tcknControl" />
    <div *ngIf="tcknControl.invalid && tcknControl.dirty">
      {{ tcknControl.errors?.['tckn'] }}
    </div>
  `,
})
export class TCKNInputComponent {
  tcknControl = new FormControl("", [this.tcknValidator]);

  tcknValidator(control: FormControl) {
    const result = validateTCKN(control.value);
    return result.isValid ? null : { tckn: result.error };
  }
}

Vanilla JavaScript Example

import { validateTaxNo } from "turkish-form-validator";

document.getElementById("tax-input").addEventListener("input", (e) => {
  const result = validateTaxNo(e.target.value);
  const errorDiv = document.getElementById("error");

  if (result.valid) {
    errorDiv.textContent = "";
    errorDiv.style.display = "none";
  } else {
    errorDiv.textContent = result.message;
    errorDiv.style.display = "block";
  }
});

Contact With

Dilara Uluturhan - LinkedIn - [email protected]


Türkçe Form Doğrulayıcı 🇹🇷

📋 Özellikler

  • TCKN Validasyonu - Türkiye Cumhuriyeti Kimlik Numarası doğrulama
  • Telefon Numarası Validasyonu - Türk cep telefonu numaralarını formatlama ile doğrulama
  • Vergi Numarası Validasyonu - Türk vergi numaralarını checksum ile doğrulama
  • Plaka Validasyonu - Türk araç plakalarını doğrulama
  • IBAN Validasyonu - Türk IBAN numaralarını doğrulama
  • TypeScript Desteği - Tam TypeScript tanımları dahil
  • Sıfır Bağımlılık - Harici bağımlılığı olmayan kütüphane

🚀 Kurulum

npm install turkish-form-validator

veya

yarn add turkish-form-validator

📖 Kullanım

TCKN Validasyonu

import { validateTCKN } from "turkish-form-validator";

const result = validateTCKN("12345678950");
if (result.isValid) {
  console.log("Geçerli TCKN");
} else {
  console.log(result.error);
}

Telefon Numarası Validasyonu

import { validateTurkishPhone } from "turkish-form-validator";

const result = validateTurkishPhone("0532 123 45 67");
if (result.valid) {
  console.log("Geçerli telefon:", result.formatted); // +905321234567
} else {
  console.log(result.message);
}

Vergi Numarası Validasyonu

import { validateTaxNo } from "turkish-form-validator";

const result = validateTaxNo("1234567890");
if (result.valid) {
  console.log("Geçerli vergi numarası:", result.formatted);
} else {
  console.log(result.message);
}

Kurumsal (Ltd./A.Ş.) mükellefler için vergi numaraları 0 ile başlayabilir. Bu senaryoları desteklemek için ikinci parametre olarak isCorporate: true gönderebilirsiniz:

const corporateResult = validateTaxNo("0000000005", { isCorporate: true });
console.log(corporateResult.valid); // true

Plaka Validasyonu

import { validateTurkishPlate } from "turkish-form-validator";

const result = validateTurkishPlate("06 ABC 123");
if (result.valid) {
  console.log("Geçerli plaka:", result.formatted);
  console.log("İl:", result.cityName);
  console.log("Tip:", result.plateType);
} else {
  console.log(result.message);
}

IBAN Validasyonu

import { validateTurkishIBAN } from "turkish-form-validator";

const result = validateTurkishIBAN("TR330006100519786457841326");
if (result.valid) {
  console.log("Geçerli IBAN:", result.formatted);
  console.log("Banka:", result.bankName);
} else {
  console.log(result.message);
}

🎯 Framework Örnekleri

React Örneği

import { useState } from "react";
import { validateTCKN } from "turkish-form-validator";

function TCKNInput() {
  const [error, setError] = useState<string>("");

  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    const result = validateTCKN(e.target.value);
    if (!result.isValid) {
      setError(result.error || "");
    } else {
      setError("");
    }
  };

  return (
    <div>
      <input type="text" onChange={handleChange} />
      {error && <span className="error">{error}</span>}
    </div>
  );
}

Vue 3 Örneği (Composition API)

<template>
  <div>
    <input v-model="phone" @input="validate" />
    <p v-if="error" class="error">{{ error }}</p>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { validateTurkishPhone } from "turkish-form-validator";

const phone = ref("");
const error = ref("");

const validate = () => {
  const result = validateTurkishPhone(phone.value);
  error.value = result.valid ? "" : result.message;
};
</script>

Angular Örneği

import { Component } from "@angular/core";
import { FormControl, Validators } from "@angular/forms";
import { validateTCKN } from "turkish-form-validator";

@Component({
  selector: "app-tckn-input",
  template: `
    <input [formControl]="tcknControl" />
    <div *ngIf="tcknControl.invalid && tcknControl.dirty">
      {{ tcknControl.errors?.['tckn'] }}
    </div>
  `,
})
export class TCKNInputComponent {
  tcknControl = new FormControl("", [this.tcknValidator]);

  tcknValidator(control: FormControl) {
    const result = validateTCKN(control.value);
    return result.isValid ? null : { tckn: result.error };
  }
}

JavaScript Örneği

import { validateTaxNo } from "turkish-form-validator";

document.getElementById("tax-input").addEventListener("input", (e) => {
  const result = validateTaxNo(e.target.value);
  const errorDiv = document.getElementById("error");

  if (result.valid) {
    errorDiv.textContent = "";
    errorDiv.style.display = "none";
  } else {
    errorDiv.textContent = result.message;
    errorDiv.style.display = "block";
  }
});

İletişim Kuralım

Dilara Uluturhan - LinkedIn - [email protected]