DEV Community

Cover image for I Built a Flutter Package for Turkish-Specific Form Validation
Ahmed
Ahmed

Posted on

I Built a Flutter Package for Turkish-Specific Form Validation

I Built a Flutter Package for Turkish-Specific Form Validation

If you've ever built a Flutter app targeting Turkish users, you know the pain.

You need to validate a TC Kimlik No — there's no package for that. You need to format a Turkish IBAN — you end up writing your own regex. You want a proper ₺1.250,50 currency format — good luck finding something ready-made.

So I built it myself: turkish_validators


What's inside

✅ TC Kimlik No Validation

TC Kimlik No has a real checksum algorithm behind it — it's not just "is it 11 digits." This package validates the full algorithm:

bool isValid = TcKimlik.validate('12345678901');

// Drop it straight into a TextFormField
TextFormField(
  validator: TcKimlik.formValidator,
)
Enter fullscreen mode Exit fullscreen mode

✅ Turkish IBAN (MOD-97)

Validates TR IBANs using the MOD-97 standard and formats them for display:

bool isValid = TurkishIban.validate('TR330006100519786457841326');

String formatted = TurkishIban.format('TR330006100519786457841326');
// → TR33 0006 1005 1978 6457 8413 26

TextFormField(
  validator: TurkishIban.formValidator,
)
Enter fullscreen mode Exit fullscreen mode

✅ Turkish Phone Number

Handles both 0532... and +9053... formats, plus clean formatting for display:

bool isValid = TurkishPhone.validate('05321234567');   // true
bool isValid2 = TurkishPhone.validate('+905321234567'); // true

String formatted = TurkishPhone.format('05321234567');
// → 0532 123 45 67
Enter fullscreen mode Exit fullscreen mode

✅ Turkish Lira Formatting

Proper Turkish number format with dot-as-thousands and comma-as-decimal:

String price = TurkishLira.format(1250.5);
// → ₺1.250,50

String price2 = TurkishLira.format(1250.5, showSymbol: false);
// → 1.250,50

double? amount = TurkishLira.parse('₺1.250,50');
// → 1250.50
Enter fullscreen mode Exit fullscreen mode

Installation

dependencies:
  turkish_validators: ^0.0.3
Enter fullscreen mode Exit fullscreen mode

That's it. No extra dependencies — just Flutter.


Why I built this

I kept rewriting the same validators across different projects. TC Kimlik alone has a non-trivial algorithm that I was copy-pasting between apps. IBAN formatting was always a manual job. At some point it just made sense to package it properly.

The Turkish Flutter ecosystem has a lot of talented developers but not many locale-specific utilities. Hopefully this saves someone a few hours.


Links

If you find it useful, a like on pub.dev goes a long way. And if something's missing — open an issue, I'm actively maintaining it.


tags: #flutter #dart #opensource #turkish #mobiledev

Top comments (0)