@mertcankocak/core-project 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,21 +5,102 @@ React TypeScript component library built with Vite.
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install core-project
8
+ npm install @mertcankocak/core-project
9
+ ```
10
+
11
+ ## Peer Dependencies
12
+
13
+ Bu paket aşağıdaki paketleri peer dependency olarak gerektirir:
14
+
15
+ ```bash
16
+ npm install react react-dom yup
9
17
  ```
10
18
 
11
19
  ## Usage
12
20
 
13
- ```tsx
14
- import { YourComponent } from 'core-project'
21
+ ### Yup Validators
22
+
23
+ #### T.C. Kimlik Numarası
24
+
25
+ Zorunluluk dışarıdan belirlenir. `required` belirtilmezse optional olur (varsayılan).
26
+
27
+ ```typescript
28
+ import * as yup from 'yup'
29
+ import { tcKimlikNoSchema } from '@mertcankocak/core-project'
30
+
31
+ // Optional (varsayılan)
32
+ const optionalSchema = yup.object({
33
+ tcKimlikNo: tcKimlikNoSchema()
34
+ })
35
+
36
+ // Required
37
+ const requiredSchema = yup.object({
38
+ tcKimlikNo: tcKimlikNoSchema({ required: true })
39
+ })
40
+
41
+ // Özel mesajlarla
42
+ const customSchema = yup.object({
43
+ tcKimlikNo: tcKimlikNoSchema({
44
+ required: true,
45
+ message: 'Geçersiz T.C. kimlik numarası',
46
+ requiredMessage: 'T.C. kimlik numarası boş bırakılamaz'
47
+ })
48
+ })
49
+ ```
50
+
51
+ #### Regex ve Manuel Validasyon
15
52
 
16
- function App() {
17
- return (
18
- <YourComponent />
19
- )
53
+ ```typescript
54
+ import {
55
+ TC_KIMLIK_NO_REGEX,
56
+ validateTCKimlikNo
57
+ } from '@mertcankocak/core-project'
58
+
59
+ // Regex kontrolü
60
+ const isValid = TC_KIMLIK_NO_REGEX.test('12345678901')
61
+
62
+ // Algoritma kontrolü
63
+ const isValid = validateTCKimlikNo('12345678901')
64
+ ```
65
+
66
+ ## Kullanım Örnekleri
67
+
68
+ Detaylı kullanım örnekleri için [USAGE_EXAMPLES.md](./USAGE_EXAMPLES.md) dosyasına bakın.
69
+
70
+ ### React Hook Form ile
71
+
72
+ ```typescript
73
+ import { useForm } from 'react-hook-form'
74
+ import { yupResolver } from '@hookform/resolvers/yup'
75
+ import * as yup from 'yup'
76
+ import { tcKimlikNoSchema } from '@mertcankocak/core-project'
77
+
78
+ const schema = yup.object({
79
+ name: yup.string().required(),
80
+ tcKimlikNo: tcKimlikNoSchema(), // Optional (varsayılan)
81
+ })
82
+
83
+ function MyForm() {
84
+ const { register, handleSubmit } = useForm({
85
+ resolver: yupResolver(schema),
86
+ })
87
+
88
+ // ...
20
89
  }
21
90
  ```
22
91
 
92
+ ### Formik ile
93
+
94
+ ```typescript
95
+ import { Formik } from 'formik'
96
+ import * as yup from 'yup'
97
+ import { tcKimlikNoSchema } from '@mertcankocak/core-project'
98
+
99
+ const schema = yup.object({
100
+ tcKimlikNo: tcKimlikNoSchema({ required: true }), // Required
101
+ })
102
+ ```
103
+
23
104
  ## Development
24
105
 
25
106
  ```bash
@@ -1 +1,446 @@
1
-
1
+ import * as f from "yup";
2
+ import { fileTypeFromBuffer as p } from "file-type";
3
+ const k = /^[0-9]{11}$/;
4
+ function E(i) {
5
+ if (!k.test(i))
6
+ return !1;
7
+ const t = i.split("").map(Number);
8
+ return !(t[0] === 0 || t.slice(0, 9).reduce((n, e) => n + e, 0) % 10 !== t[9] || t.slice(0, 10).reduce((n, e) => n + e, 0) % 10 !== t[10]);
9
+ }
10
+ function _(i) {
11
+ const {
12
+ required: t = !1,
13
+ message: s = "Geçerli bir T.C. kimlik numarası giriniz",
14
+ requiredMessage: a = "T.C. kimlik numarası zorunludur",
15
+ name: n = "tcKimlikNo"
16
+ } = i || {};
17
+ let e = f.string();
18
+ return t && (e = e.required(a)), e = e.matches(
19
+ k,
20
+ "T.C. kimlik numarası 11 haneli olmalıdır"
21
+ ), e = e.test({
22
+ name: n,
23
+ message: s,
24
+ test(r) {
25
+ return !t && (!r || r.trim() === "") ? !0 : t && !r || !r || typeof r != "string" ? !1 : E(r);
26
+ }
27
+ }), e;
28
+ }
29
+ const $ = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
30
+ function S(i) {
31
+ return $.test(i);
32
+ }
33
+ function L(i) {
34
+ const {
35
+ required: t = !1,
36
+ message: s = "Geçerli bir email adresi giriniz",
37
+ requiredMessage: a = "Email zorunludur",
38
+ name: n = "email"
39
+ } = i || {};
40
+ let e = f.string();
41
+ return t && (e = e.required(a)), e = e.email(s).test({
42
+ name: n,
43
+ message: s,
44
+ test(r) {
45
+ return !t && (!r || r.trim() === "") ? !0 : t && !r || !r || typeof r != "string" ? !1 : S(r);
46
+ }
47
+ }), e;
48
+ }
49
+ const T = /^(\+90\s?)?(0?5\d{2})\s?(\d{3})\s?(\d{2})\s?(\d{2})$/;
50
+ function x(i) {
51
+ const t = i.replace(/\s+/g, "").replace(/[-\+()]/g, "");
52
+ return t.length !== 10 && t.length !== 11 || !t.match(/^(0?5\d{9})$/) ? !1 : T.test(i) || /^0?5\d{9}$/.test(t);
53
+ }
54
+ function V(i) {
55
+ const {
56
+ required: t = !1,
57
+ message: s = "Geçerli bir telefon numarası giriniz (05XX XXX XX XX)",
58
+ requiredMessage: a = "Telefon numarası zorunludur",
59
+ name: n = "phone"
60
+ } = i || {};
61
+ let e = f.string();
62
+ return t && (e = e.required(a)), e = e.test({
63
+ name: n,
64
+ message: s,
65
+ test(r) {
66
+ return !t && (!r || r.trim() === "") ? !0 : t && !r || !r || typeof r != "string" ? !1 : x(r);
67
+ }
68
+ }), e;
69
+ }
70
+ function j(i, t) {
71
+ const {
72
+ minLength: s = 8,
73
+ requireUppercase: a = !0,
74
+ requireLowercase: n = !0,
75
+ requireNumber: e = !0,
76
+ requireSpecialChar: r = !0
77
+ } = t || {}, u = [];
78
+ return i.length < s && u.push(`Şifre en az ${s} karakter olmalıdır`), a && !/[A-Z]/.test(i) && u.push("Şifre en az bir büyük harf içermelidir"), n && !/[a-z]/.test(i) && u.push("Şifre en az bir küçük harf içermelidir"), e && !/\d/.test(i) && u.push("Şifre en az bir rakam içermelidir"), r && !/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(i) && u.push("Şifre en az bir özel karakter içermelidir"), {
79
+ isValid: u.length === 0,
80
+ errors: u
81
+ };
82
+ }
83
+ function F(i) {
84
+ const {
85
+ required: t = !1,
86
+ requiredMessage: s = "Şifre zorunludur",
87
+ minLength: a = 8,
88
+ requireUppercase: n = !0,
89
+ requireLowercase: e = !0,
90
+ requireNumber: r = !0,
91
+ requireSpecialChar: u = !0,
92
+ minLengthMessage: l = `Şifre en az ${a} karakter olmalıdır`,
93
+ uppercaseMessage: c = "Şifre en az bir büyük harf içermelidir",
94
+ lowercaseMessage: h = "Şifre en az bir küçük harf içermelidir",
95
+ numberMessage: d = "Şifre en az bir rakam içermelidir",
96
+ specialCharMessage: m = "Şifre en az bir özel karakter içermelidir"
97
+ } = i || {};
98
+ let o = f.string();
99
+ return t && (o = o.required(s)), o = o.min(a, l), n && (o = o.matches(/[A-Z]/, c)), e && (o = o.matches(/[a-z]/, h)), r && (o = o.matches(/\d/, d)), u && (o = o.matches(
100
+ /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/,
101
+ m
102
+ )), o;
103
+ }
104
+ function K(i, t) {
105
+ const {
106
+ required: s = !1,
107
+ message: a = "Şifreler eşleşmiyor",
108
+ requiredMessage: n = "Şifre tekrarı zorunludur"
109
+ } = t || {};
110
+ let e = f.string();
111
+ return s && (e = e.required(n)), e = e.oneOf([f.ref(i)], a), e;
112
+ }
113
+ const b = /^[a-zA-ZçğıöşüÇĞIİÖŞÜ\s]+$/;
114
+ function A(i) {
115
+ return !i || i.trim().length === 0 || i.trim().length < 2 ? !1 : b.test(i);
116
+ }
117
+ function Z(i) {
118
+ const {
119
+ required: t = !1,
120
+ message: s = "İsim sadece harf içermelidir",
121
+ requiredMessage: a = "İsim zorunludur",
122
+ name: n = "name"
123
+ } = i || {};
124
+ let e = f.string();
125
+ return t && (e = e.required(a)), e = e.min(2, "İsim en az 2 karakter olmalıdır").matches(b, s).test({
126
+ name: n,
127
+ message: s,
128
+ test(r) {
129
+ return !t && (!r || r.trim() === "") ? !0 : t && !r || !r || typeof r != "string" ? !1 : A(r);
130
+ }
131
+ }), e;
132
+ }
133
+ const w = /^TR\d{2}[0-9A-Z]{4}\d{1}[0-9A-Z]{15,30}$/i;
134
+ function B(i) {
135
+ const t = i.replace(/\s+/g, "").toUpperCase();
136
+ if (!w.test(t))
137
+ return !1;
138
+ const a = (t.slice(4) + t.slice(0, 4)).split("").map((e) => {
139
+ const r = e.charCodeAt(0);
140
+ return r >= 65 && r <= 90 ? r - 55 : e;
141
+ }).join("");
142
+ return BigInt(a) % BigInt(97) === BigInt(1);
143
+ }
144
+ function O(i) {
145
+ const {
146
+ required: t = !1,
147
+ message: s = "Geçerli bir IBAN numarası giriniz",
148
+ requiredMessage: a = "IBAN zorunludur",
149
+ name: n = "iban"
150
+ } = i || {};
151
+ let e = f.string();
152
+ return t && (e = e.required(a)), e = e.test({
153
+ name: n,
154
+ message: s,
155
+ test(r) {
156
+ return !t && (!r || r.trim() === "") ? !0 : t && !r || !r || typeof r != "string" ? !1 : B(r);
157
+ }
158
+ }), e;
159
+ }
160
+ const N = /^\d{13,19}$/;
161
+ function C(i) {
162
+ const t = i.replace(/\s+/g, "").replace(/-/g, "");
163
+ if (!N.test(t))
164
+ return !1;
165
+ let s = 0, a = !1;
166
+ for (let n = t.length - 1; n >= 0; n--) {
167
+ let e = parseInt(t[n], 10);
168
+ a && (e *= 2, e > 9 && (e -= 9)), s += e, a = !a;
169
+ }
170
+ return s % 10 === 0;
171
+ }
172
+ function U(i) {
173
+ const {
174
+ required: t = !1,
175
+ message: s = "Geçerli bir kredi kartı numarası giriniz",
176
+ requiredMessage: a = "Kredi kartı numarası zorunludur",
177
+ name: n = "creditCard"
178
+ } = i || {};
179
+ let e = f.string();
180
+ return t && (e = e.required(a)), e = e.test({
181
+ name: n,
182
+ message: s,
183
+ test(r) {
184
+ return !t && (!r || r.trim() === "") ? !0 : t && !r || !r || typeof r != "string" ? !1 : C(r);
185
+ }
186
+ }), e;
187
+ }
188
+ const G = /^\d{10}$/;
189
+ function X(i) {
190
+ if (!G.test(i))
191
+ return !1;
192
+ const t = i.split("").map(Number);
193
+ return t.slice(0, 9).reduce((n, e, r) => {
194
+ const u = (r + 1) % 9 || 9;
195
+ return n + e * u;
196
+ }, 0) % 11 % 10 === t[9];
197
+ }
198
+ function P(i) {
199
+ const {
200
+ required: t = !1,
201
+ message: s = "Geçerli bir VKN (Vergi Kimlik Numarası) giriniz",
202
+ requiredMessage: a = "VKN zorunludur",
203
+ name: n = "vkn"
204
+ } = i || {};
205
+ let e = f.string();
206
+ return t && (e = e.required(a)), e = e.test({
207
+ name: n,
208
+ message: s,
209
+ test(r) {
210
+ return !t && (!r || r.trim() === "") ? !0 : t && !r || !r || typeof r != "string" ? !1 : X(r);
211
+ }
212
+ }), e;
213
+ }
214
+ const z = /^(\d{2})\s?([A-ZÇĞIİÖŞÜ]{1,3})\s?(\d{2,4})$/i;
215
+ function I(i) {
216
+ const t = i.replace(/\s+/g, " ").trim().toUpperCase();
217
+ if (!z.test(t))
218
+ return !1;
219
+ const s = t.match(z);
220
+ if (!s)
221
+ return !1;
222
+ const [, a, n, e] = s, r = parseInt(a, 10);
223
+ return !(r < 1 || r > 81 || n.length < 1 || n.length > 3 || e.length < 2 || e.length > 4);
224
+ }
225
+ function H(i) {
226
+ const {
227
+ required: t = !1,
228
+ message: s = "Geçerli bir araç plakası giriniz (örn: 34 ABC 123)",
229
+ requiredMessage: a = "Araç plakası zorunludur",
230
+ name: n = "plate"
231
+ } = i || {};
232
+ let e = f.string();
233
+ return t && (e = e.required(a)), e = e.test({
234
+ name: n,
235
+ message: s,
236
+ test(r) {
237
+ return !t && (!r || r.trim() === "") ? !0 : t && !r || !r || typeof r != "string" ? !1 : I(r);
238
+ }
239
+ }), e;
240
+ }
241
+ function g(i) {
242
+ const t = i.split(".");
243
+ return t.length > 1 ? t[t.length - 1].toLowerCase() : "";
244
+ }
245
+ async function Y(i, t) {
246
+ const {
247
+ maxSize: s,
248
+ minSize: a,
249
+ allowedExtensions: n = [],
250
+ allowedMimeTypes: e = []
251
+ } = t || {}, r = [];
252
+ if (s && i.size > s) {
253
+ const u = (s / 1048576).toFixed(2);
254
+ r.push(`Dosya boyutu en fazla ${u} MB olmalıdır`);
255
+ }
256
+ if (a && i.size < a) {
257
+ const u = (a / 1048576).toFixed(2);
258
+ r.push(`Dosya boyutu en az ${u} MB olmalıdır`);
259
+ }
260
+ if (n.length > 0 && e.length === 0 && console.warn(
261
+ "⚠️ UYARI: Sadece dosya uzantısı kontrolü yapılıyor. Güvenlik için 'allowedMimeTypes' parametresini kullanarak magic bytes kontrolü yapmanız önerilir."
262
+ ), n.length > 0 && i instanceof File) {
263
+ const u = g(i.name);
264
+ n.includes(u) || r.push(
265
+ `İzin verilen dosya uzantıları: ${n.join(", ")}`
266
+ );
267
+ }
268
+ if (e.length > 0)
269
+ try {
270
+ const u = await i.arrayBuffer(), l = new Uint8Array(u), c = await p(l);
271
+ c ? e.includes(c.mime) || r.push(
272
+ `Dosya tipi uyumsuz. Beklenen: ${e.join(", ")}, Tespit edilen: ${c.mime}. (Dosya uzantısı: ${i instanceof File ? g(i.name) : "bilinmiyor"})`
273
+ ) : r.push(
274
+ "Dosya tipi belirlenemedi. Dosya bozuk olabilir veya desteklenmeyen bir formatta olabilir."
275
+ );
276
+ } catch {
277
+ r.push("Dosya tipi kontrol edilemedi. Dosya okunamadı.");
278
+ }
279
+ return {
280
+ isValid: r.length === 0,
281
+ errors: r
282
+ };
283
+ }
284
+ function J(i) {
285
+ const {
286
+ required: t = !1,
287
+ message: s = "Geçerli bir dosya seçiniz",
288
+ requiredMessage: a = "Dosya zorunludur",
289
+ name: n = "file",
290
+ maxSize: e,
291
+ minSize: r,
292
+ allowedExtensions: u = [],
293
+ allowedMimeTypes: l = [],
294
+ sizeMessage: c,
295
+ extensionMessage: h
296
+ } = i || {};
297
+ let d = f.mixed();
298
+ return t && (d = d.required(a)), d = d.test({
299
+ name: n,
300
+ message: s || "Geçerli bir dosya seçiniz",
301
+ async test(m) {
302
+ if (!t && !m)
303
+ return !0;
304
+ if (t && !m || !(m instanceof File))
305
+ return !1;
306
+ if (e && m.size > e) {
307
+ const o = (e / 1048576).toFixed(2);
308
+ return this.createError({
309
+ message: c || `Dosya boyutu en fazla ${o} MB olmalıdır`
310
+ });
311
+ }
312
+ if (r && m.size < r) {
313
+ const o = (r / 1048576).toFixed(2);
314
+ return this.createError({
315
+ message: c || `Dosya boyutu en az ${o} MB olmalıdır`
316
+ });
317
+ }
318
+ if (u.length > 0) {
319
+ const o = g(m.name);
320
+ if (!u.includes(o))
321
+ return this.createError({
322
+ message: h || `İzin verilen dosya uzantıları: ${u.join(", ")}`
323
+ });
324
+ }
325
+ if (l.length > 0)
326
+ try {
327
+ const o = await m.arrayBuffer(), q = new Uint8Array(o), y = await p(q);
328
+ if (!y)
329
+ return this.createError({
330
+ message: "Dosya tipi belirlenemedi. Dosya bozuk olabilir veya desteklenmeyen bir formatta olabilir."
331
+ });
332
+ if (!l.includes(y.mime)) {
333
+ const M = g(m.name);
334
+ return this.createError({
335
+ message: `Dosya tipi uyumsuz. Beklenen: ${l.join(
336
+ ", "
337
+ )}, Tespit edilen: ${y.mime}. (Dosya uzantısı: ${M})`
338
+ });
339
+ }
340
+ } catch {
341
+ return this.createError({
342
+ message: "Dosya tipi kontrol edilemedi. Dosya okunamadı."
343
+ });
344
+ }
345
+ return !0;
346
+ }
347
+ }), d;
348
+ }
349
+ function Q(i, t) {
350
+ const { minDate: s, maxDate: a } = t || {}, n = typeof i == "string" ? new Date(i) : i;
351
+ if (isNaN(n.getTime()))
352
+ return { isValid: !1, error: "Geçersiz tarih formatı" };
353
+ if (s) {
354
+ const e = typeof s == "string" ? new Date(s) : s;
355
+ if (n < e)
356
+ return {
357
+ isValid: !1,
358
+ error: `Tarih ${e.toLocaleDateString("tr-TR")} tarihinden sonra olmalıdır`
359
+ };
360
+ }
361
+ if (a) {
362
+ const e = typeof a == "string" ? new Date(a) : a;
363
+ if (n > e)
364
+ return {
365
+ isValid: !1,
366
+ error: `Tarih ${e.toLocaleDateString("tr-TR")} tarihinden önce olmalıdır`
367
+ };
368
+ }
369
+ return { isValid: !0 };
370
+ }
371
+ function D(i) {
372
+ const {
373
+ required: t = !1,
374
+ requiredMessage: s = "Tarih zorunludur",
375
+ minDate: a,
376
+ maxDate: n,
377
+ minDateMessage: e,
378
+ maxDateMessage: r
379
+ } = i || {};
380
+ let u = f.date();
381
+ if (t && (u = u.required(s)), a) {
382
+ const l = typeof a == "string" ? new Date(a) : a;
383
+ u = u.min(
384
+ l,
385
+ e || `Tarih ${l.toLocaleDateString("tr-TR")} tarihinden sonra olmalıdır`
386
+ );
387
+ }
388
+ if (n) {
389
+ const l = typeof n == "string" ? new Date(n) : n;
390
+ u = u.max(
391
+ l,
392
+ r || `Tarih ${l.toLocaleDateString("tr-TR")} tarihinden önce olmalıdır`
393
+ );
394
+ }
395
+ return u;
396
+ }
397
+ function W(i) {
398
+ return D({
399
+ ...i,
400
+ maxDate: /* @__PURE__ */ new Date(),
401
+ maxDateMessage: (i == null ? void 0 : i.message) || "Tarih geçmiş bir tarih olmalıdır"
402
+ });
403
+ }
404
+ function v(i) {
405
+ return D({
406
+ ...i,
407
+ minDate: /* @__PURE__ */ new Date(),
408
+ minDateMessage: (i == null ? void 0 : i.message) || "Tarih gelecek bir tarih olmalıdır"
409
+ });
410
+ }
411
+ export {
412
+ N as CREDIT_CARD_REGEX,
413
+ $ as EMAIL_REGEX,
414
+ w as IBAN_REGEX,
415
+ b as NAME_REGEX,
416
+ T as PHONE_REGEX,
417
+ z as PLATE_REGEX,
418
+ k as TC_KIMLIK_NO_REGEX,
419
+ G as VKN_REGEX,
420
+ U as creditCardSchema,
421
+ D as dateSchema,
422
+ L as emailSchema,
423
+ J as fileSchema,
424
+ v as futureDateSchema,
425
+ g as getFileExtension,
426
+ O as ibanSchema,
427
+ Z as nameSchema,
428
+ K as passwordMatchSchema,
429
+ F as passwordSchema,
430
+ W as pastDateSchema,
431
+ V as phoneSchema,
432
+ H as plateSchema,
433
+ _ as tcKimlikNoSchema,
434
+ C as validateCreditCard,
435
+ Q as validateDate,
436
+ S as validateEmail,
437
+ Y as validateFile,
438
+ B as validateIBAN,
439
+ A as validateName,
440
+ j as validatePassword,
441
+ x as validatePhone,
442
+ I as validatePlate,
443
+ E as validateTCKimlikNo,
444
+ X as validateVKN,
445
+ P as vknSchema
446
+ };
@@ -1 +1 @@
1
- (function(n){typeof define=="function"&&define.amd?define(n):n()})(function(){"use strict"});
1
+ (function(u,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("yup"),require("file-type")):typeof define=="function"&&define.amd?define(["exports","yup","file-type"],h):(u=typeof globalThis<"u"?globalThis:u||self,h(u.CoreProject={},u.Yup,u.FileType))})(this,function(u,h,S){"use strict";function I(i){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const a in i)if(a!=="default"){const n=Object.getOwnPropertyDescriptor(i,a);Object.defineProperty(t,a,n.get?n:{enumerable:!0,get:()=>i[a]})}}return t.default=i,Object.freeze(t)}const m=I(h),z=/^[0-9]{11}$/;function q(i){if(!z.test(i))return!1;const t=i.split("").map(Number);return!(t[0]===0||t.slice(0,9).reduce((s,e)=>s+e,0)%10!==t[9]||t.slice(0,10).reduce((s,e)=>s+e,0)%10!==t[10])}function j(i){const{required:t=!1,message:a="Geçerli bir T.C. kimlik numarası giriniz",requiredMessage:n="T.C. kimlik numarası zorunludur",name:s="tcKimlikNo"}=i||{};let e=m.string();return t&&(e=e.required(n)),e=e.matches(z,"T.C. kimlik numarası 11 haneli olmalıdır"),e=e.test({name:s,message:a,test(r){return!t&&(!r||r.trim()==="")?!0:t&&!r||!r||typeof r!="string"?!1:q(r)}}),e}const M=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;function T(i){return M.test(i)}function K(i){const{required:t=!1,message:a="Geçerli bir email adresi giriniz",requiredMessage:n="Email zorunludur",name:s="email"}=i||{};let e=m.string();return t&&(e=e.required(n)),e=e.email(a).test({name:s,message:a,test(r){return!t&&(!r||r.trim()==="")?!0:t&&!r||!r||typeof r!="string"?!1:T(r)}}),e}const N=/^(\+90\s?)?(0?5\d{2})\s?(\d{3})\s?(\d{2})\s?(\d{2})$/;function $(i){const t=i.replace(/\s+/g,"").replace(/[-\+()]/g,"");return t.length!==10&&t.length!==11||!t.match(/^(0?5\d{9})$/)?!1:N.test(i)||/^0?5\d{9}$/.test(t)}function L(i){const{required:t=!1,message:a="Geçerli bir telefon numarası giriniz (05XX XXX XX XX)",requiredMessage:n="Telefon numarası zorunludur",name:s="phone"}=i||{};let e=m.string();return t&&(e=e.required(n)),e=e.test({name:s,message:a,test(r){return!t&&(!r||r.trim()==="")?!0:t&&!r||!r||typeof r!="string"?!1:$(r)}}),e}function O(i,t){const{minLength:a=8,requireUppercase:n=!0,requireLowercase:s=!0,requireNumber:e=!0,requireSpecialChar:r=!0}=t||{},l=[];return i.length<a&&l.push(`Şifre en az ${a} karakter olmalıdır`),n&&!/[A-Z]/.test(i)&&l.push("Şifre en az bir büyük harf içermelidir"),s&&!/[a-z]/.test(i)&&l.push("Şifre en az bir küçük harf içermelidir"),e&&!/\d/.test(i)&&l.push("Şifre en az bir rakam içermelidir"),r&&!/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(i)&&l.push("Şifre en az bir özel karakter içermelidir"),{isValid:l.length===0,errors:l}}function F(i){const{required:t=!1,requiredMessage:a="Şifre zorunludur",minLength:n=8,requireUppercase:s=!0,requireLowercase:e=!0,requireNumber:r=!0,requireSpecialChar:l=!0,minLengthMessage:o=`Şifre en az ${n} karakter olmalıdır`,uppercaseMessage:d="Şifre en az bir büyük harf içermelidir",lowercaseMessage:D="Şifre en az bir küçük harf içermelidir",numberMessage:g="Şifre en az bir rakam içermelidir",specialCharMessage:c="Şifre en az bir özel karakter içermelidir"}=i||{};let f=m.string();return t&&(f=f.required(a)),f=f.min(n,o),s&&(f=f.matches(/[A-Z]/,d)),e&&(f=f.matches(/[a-z]/,D)),r&&(f=f.matches(/\d/,g)),l&&(f=f.matches(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/,c)),f}function P(i,t){const{required:a=!1,message:n="Şifreler eşleşmiyor",requiredMessage:s="Şifre tekrarı zorunludur"}=t||{};let e=m.string();return a&&(e=e.required(s)),e=e.oneOf([m.ref(i)],n),e}const b=/^[a-zA-ZçğıöşüÇĞIİÖŞÜ\s]+$/;function A(i){return!i||i.trim().length===0||i.trim().length<2?!1:b.test(i)}function V(i){const{required:t=!1,message:a="İsim sadece harf içermelidir",requiredMessage:n="İsim zorunludur",name:s="name"}=i||{};let e=m.string();return t&&(e=e.required(n)),e=e.min(2,"İsim en az 2 karakter olmalıdır").matches(b,a).test({name:s,message:a,test(r){return!t&&(!r||r.trim()==="")?!0:t&&!r||!r||typeof r!="string"?!1:A(r)}}),e}const C=/^TR\d{2}[0-9A-Z]{4}\d{1}[0-9A-Z]{15,30}$/i;function _(i){const t=i.replace(/\s+/g,"").toUpperCase();if(!C.test(t))return!1;const n=(t.slice(4)+t.slice(0,4)).split("").map(e=>{const r=e.charCodeAt(0);return r>=65&&r<=90?r-55:e}).join("");return BigInt(n)%BigInt(97)===BigInt(1)}function Z(i){const{required:t=!1,message:a="Geçerli bir IBAN numarası giriniz",requiredMessage:n="IBAN zorunludur",name:s="iban"}=i||{};let e=m.string();return t&&(e=e.required(n)),e=e.test({name:s,message:a,test(r){return!t&&(!r||r.trim()==="")?!0:t&&!r||!r||typeof r!="string"?!1:_(r)}}),e}const w=/^\d{13,19}$/;function G(i){const t=i.replace(/\s+/g,"").replace(/-/g,"");if(!w.test(t))return!1;let a=0,n=!1;for(let s=t.length-1;s>=0;s--){let e=parseInt(t[s],10);n&&(e*=2,e>9&&(e-=9)),a+=e,n=!n}return a%10===0}function U(i){const{required:t=!1,message:a="Geçerli bir kredi kartı numarası giriniz",requiredMessage:n="Kredi kartı numarası zorunludur",name:s="creditCard"}=i||{};let e=m.string();return t&&(e=e.required(n)),e=e.test({name:s,message:a,test(r){return!t&&(!r||r.trim()==="")?!0:t&&!r||!r||typeof r!="string"?!1:G(r)}}),e}const B=/^\d{10}$/;function R(i){if(!B.test(i))return!1;const t=i.split("").map(Number);return t.slice(0,9).reduce((s,e,r)=>{const l=(r+1)%9||9;return s+e*l},0)%11%10===t[9]}function H(i){const{required:t=!1,message:a="Geçerli bir VKN (Vergi Kimlik Numarası) giriniz",requiredMessage:n="VKN zorunludur",name:s="vkn"}=i||{};let e=m.string();return t&&(e=e.required(n)),e=e.test({name:s,message:a,test(r){return!t&&(!r||r.trim()==="")?!0:t&&!r||!r||typeof r!="string"?!1:R(r)}}),e}const k=/^(\d{2})\s?([A-ZÇĞIİÖŞÜ]{1,3})\s?(\d{2,4})$/i;function X(i){const t=i.replace(/\s+/g," ").trim().toUpperCase();if(!k.test(t))return!1;const a=t.match(k);if(!a)return!1;const[,n,s,e]=a,r=parseInt(n,10);return!(r<1||r>81||s.length<1||s.length>3||e.length<2||e.length>4)}function Y(i){const{required:t=!1,message:a="Geçerli bir araç plakası giriniz (örn: 34 ABC 123)",requiredMessage:n="Araç plakası zorunludur",name:s="plate"}=i||{};let e=m.string();return t&&(e=e.required(n)),e=e.test({name:s,message:a,test(r){return!t&&(!r||r.trim()==="")?!0:t&&!r||!r||typeof r!="string"?!1:X(r)}}),e}function y(i){const t=i.split(".");return t.length>1?t[t.length-1].toLowerCase():""}async function J(i,t){const{maxSize:a,minSize:n,allowedExtensions:s=[],allowedMimeTypes:e=[]}=t||{},r=[];if(a&&i.size>a){const l=(a/1048576).toFixed(2);r.push(`Dosya boyutu en fazla ${l} MB olmalıdır`)}if(n&&i.size<n){const l=(n/1048576).toFixed(2);r.push(`Dosya boyutu en az ${l} MB olmalıdır`)}if(s.length>0&&e.length===0&&console.warn("⚠️ UYARI: Sadece dosya uzantısı kontrolü yapılıyor. Güvenlik için 'allowedMimeTypes' parametresini kullanarak magic bytes kontrolü yapmanız önerilir."),s.length>0&&i instanceof File){const l=y(i.name);s.includes(l)||r.push(`İzin verilen dosya uzantıları: ${s.join(", ")}`)}if(e.length>0)try{const l=await i.arrayBuffer(),o=new Uint8Array(l),d=await S.fileTypeFromBuffer(o);d?e.includes(d.mime)||r.push(`Dosya tipi uyumsuz. Beklenen: ${e.join(", ")}, Tespit edilen: ${d.mime}. (Dosya uzantısı: ${i instanceof File?y(i.name):"bilinmiyor"})`):r.push("Dosya tipi belirlenemedi. Dosya bozuk olabilir veya desteklenmeyen bir formatta olabilir.")}catch{r.push("Dosya tipi kontrol edilemedi. Dosya okunamadı.")}return{isValid:r.length===0,errors:r}}function Q(i){const{required:t=!1,message:a="Geçerli bir dosya seçiniz",requiredMessage:n="Dosya zorunludur",name:s="file",maxSize:e,minSize:r,allowedExtensions:l=[],allowedMimeTypes:o=[],sizeMessage:d,extensionMessage:D}=i||{};let g=m.mixed();return t&&(g=g.required(n)),g=g.test({name:s,message:a||"Geçerli bir dosya seçiniz",async test(c){if(!t&&!c)return!0;if(t&&!c||!(c instanceof File))return!1;if(e&&c.size>e){const f=(e/1048576).toFixed(2);return this.createError({message:d||`Dosya boyutu en fazla ${f} MB olmalıdır`})}if(r&&c.size<r){const f=(r/1048576).toFixed(2);return this.createError({message:d||`Dosya boyutu en az ${f} MB olmalıdır`})}if(l.length>0){const f=y(c.name);if(!l.includes(f))return this.createError({message:D||`İzin verilen dosya uzantıları: ${l.join(", ")}`})}if(o.length>0)try{const f=await c.arrayBuffer(),ee=new Uint8Array(f),E=await S.fileTypeFromBuffer(ee);if(!E)return this.createError({message:"Dosya tipi belirlenemedi. Dosya bozuk olabilir veya desteklenmeyen bir formatta olabilir."});if(!o.includes(E.mime)){const re=y(c.name);return this.createError({message:`Dosya tipi uyumsuz. Beklenen: ${o.join(", ")}, Tespit edilen: ${E.mime}. (Dosya uzantısı: ${re})`})}}catch{return this.createError({message:"Dosya tipi kontrol edilemedi. Dosya okunamadı."})}return!0}}),g}function W(i,t){const{minDate:a,maxDate:n}=t||{},s=typeof i=="string"?new Date(i):i;if(isNaN(s.getTime()))return{isValid:!1,error:"Geçersiz tarih formatı"};if(a){const e=typeof a=="string"?new Date(a):a;if(s<e)return{isValid:!1,error:`Tarih ${e.toLocaleDateString("tr-TR")} tarihinden sonra olmalıdır`}}if(n){const e=typeof n=="string"?new Date(n):n;if(s>e)return{isValid:!1,error:`Tarih ${e.toLocaleDateString("tr-TR")} tarihinden önce olmalıdır`}}return{isValid:!0}}function p(i){const{required:t=!1,requiredMessage:a="Tarih zorunludur",minDate:n,maxDate:s,minDateMessage:e,maxDateMessage:r}=i||{};let l=m.date();if(t&&(l=l.required(a)),n){const o=typeof n=="string"?new Date(n):n;l=l.min(o,e||`Tarih ${o.toLocaleDateString("tr-TR")} tarihinden sonra olmalıdır`)}if(s){const o=typeof s=="string"?new Date(s):s;l=l.max(o,r||`Tarih ${o.toLocaleDateString("tr-TR")} tarihinden önce olmalıdır`)}return l}function x(i){return p({...i,maxDate:new Date,maxDateMessage:(i==null?void 0:i.message)||"Tarih geçmiş bir tarih olmalıdır"})}function v(i){return p({...i,minDate:new Date,minDateMessage:(i==null?void 0:i.message)||"Tarih gelecek bir tarih olmalıdır"})}u.CREDIT_CARD_REGEX=w,u.EMAIL_REGEX=M,u.IBAN_REGEX=C,u.NAME_REGEX=b,u.PHONE_REGEX=N,u.PLATE_REGEX=k,u.TC_KIMLIK_NO_REGEX=z,u.VKN_REGEX=B,u.creditCardSchema=U,u.dateSchema=p,u.emailSchema=K,u.fileSchema=Q,u.futureDateSchema=v,u.getFileExtension=y,u.ibanSchema=Z,u.nameSchema=V,u.passwordMatchSchema=P,u.passwordSchema=F,u.pastDateSchema=x,u.phoneSchema=L,u.plateSchema=Y,u.tcKimlikNoSchema=j,u.validateCreditCard=G,u.validateDate=W,u.validateEmail=T,u.validateFile=J,u.validateIBAN=_,u.validateName=A,u.validatePassword=O,u.validatePhone=$,u.validatePlate=X,u.validateTCKimlikNo=q,u.validateVKN=R,u.vknSchema=H,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
+ export * from './validators';
1
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { ValidatorOptions } from './types';
2
+ import * as yup from "yup";
3
+ /**
4
+ * Kredi kartı numarası regex'i (sadece rakamlar, 13-19 hane)
5
+ */
6
+ export declare const CREDIT_CARD_REGEX: RegExp;
7
+ /**
8
+ * Luhn algoritması ile kredi kartı validasyonu
9
+ */
10
+ export declare function validateCreditCard(cardNumber: string): boolean;
11
+ /**
12
+ * Kredi kartı için yup schema
13
+ */
14
+ export declare function creditCardSchema(options?: ValidatorOptions): yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
15
+ //# sourceMappingURL=creditCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creditCard.d.ts","sourceRoot":"","sources":["../../src/validators/creditCard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAgB,CAAC;AAE/C;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CA6B9D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,gBAAgB,sEAmC1D"}
@@ -0,0 +1,22 @@
1
+ import { DateValidatorOptions, ValidatorOptions } from './types';
2
+ import * as yup from "yup";
3
+ /**
4
+ * Tarih validasyonu
5
+ */
6
+ export declare function validateDate(date: Date | string, options?: Omit<DateValidatorOptions, "required" | "message" | "requiredMessage" | "name">): {
7
+ isValid: boolean;
8
+ error?: string;
9
+ };
10
+ /**
11
+ * Tarih için yup schema
12
+ */
13
+ export declare function dateSchema(options?: DateValidatorOptions): yup.DateSchema<Date | undefined, yup.AnyObject, undefined, "">;
14
+ /**
15
+ * Geçmiş tarih kontrolü
16
+ */
17
+ export declare function pastDateSchema(options?: ValidatorOptions): yup.DateSchema<Date | undefined, yup.AnyObject, undefined, "">;
18
+ /**
19
+ * Gelecek tarih kontrolü
20
+ */
21
+ export declare function futureDateSchema(options?: ValidatorOptions): yup.DateSchema<Date | undefined, yup.AnyObject, undefined, "">;
22
+ //# sourceMappingURL=date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/validators/date.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEtE;;GAEG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,IAAI,GAAG,MAAM,EACnB,OAAO,CAAC,EAAE,IAAI,CACZ,oBAAoB,EACpB,UAAU,GAAG,SAAS,GAAG,iBAAiB,GAAG,MAAM,CACpD,GACA;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAgCtC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,oBAAoB,kEAqCxD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,gBAAgB,kEAMxD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,gBAAgB,kEAM1D"}
@@ -0,0 +1,15 @@
1
+ import { ValidatorOptions } from './types';
2
+ import * as yup from "yup";
3
+ /**
4
+ * Türkiye email formatı regex'i
5
+ */
6
+ export declare const EMAIL_REGEX: RegExp;
7
+ /**
8
+ * Email validasyonu
9
+ */
10
+ export declare function validateEmail(email: string): boolean;
11
+ /**
12
+ * Email için yup schema
13
+ */
14
+ export declare function emailSchema(options?: ValidatorOptions): yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
15
+ //# sourceMappingURL=email.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/validators/email.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,WAAW,QAAqD,CAAC;AAE9E;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,gBAAgB,sEAmCrD"}
@@ -0,0 +1,46 @@
1
+ import { FileValidatorOptions } from './types';
2
+ import * as yup from "yup";
3
+ /**
4
+ * Dosya uzantısını al
5
+ */
6
+ export declare function getFileExtension(filename: string): string;
7
+ /**
8
+ * Dosya validasyonu
9
+ *
10
+ * ÖNEMLİ: Dosya uzantısı kontrolü yeterli değildir!
11
+ * Gerçek dosya tipini belirlemek için magic bytes kontrolü yapılmalıdır.
12
+ *
13
+ * Magic bytes: Dosyanın içeriğinin ilk birkaç byte'ına bakarak
14
+ * gerçek dosya tipini belirler. Örneğin:
15
+ * - PDF: %PDF- (ilk 5 byte)
16
+ * - JPEG: FF D8 FF
17
+ * - PNG: 89 50 4E 47
18
+ *
19
+ * Bu sayede birisi bir .exe dosyasını .pdf olarak adlandırsa bile,
20
+ * magic bytes kontrolü ile gerçek tipi tespit edilir.
21
+ */
22
+ export declare function validateFile(file: File | Blob, options?: Omit<FileValidatorOptions, "required" | "message" | "requiredMessage" | "name">): Promise<{
23
+ isValid: boolean;
24
+ errors: string[];
25
+ }>;
26
+ /**
27
+ * Dosya için yup schema
28
+ *
29
+ * ÖNEMLİ: Güvenlik için mutlaka 'allowedMimeTypes' kullanın!
30
+ *
31
+ * Örnek kullanım:
32
+ * ```ts
33
+ * // ✅ DOĞRU: Magic bytes kontrolü ile
34
+ * fileSchema({
35
+ * allowedExtensions: ['pdf'],
36
+ * allowedMimeTypes: ['application/pdf'] // Magic bytes kontrolü yapar
37
+ * })
38
+ *
39
+ * // ⚠️ YETERSİZ: Sadece uzantı kontrolü (güvenli değil)
40
+ * fileSchema({
41
+ * allowedExtensions: ['pdf'] // Birisi .exe dosyasını .pdf olarak adlandırabilir!
42
+ * })
43
+ * ```
44
+ */
45
+ export declare function fileSchema(options?: FileValidatorOptions): yup.MixedSchema<File | undefined, yup.AnyObject, undefined, "">;
46
+ //# sourceMappingURL=file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/validators/file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,IAAI,GAAG,IAAI,EACjB,OAAO,CAAC,EAAE,IAAI,CACZ,oBAAoB,EACpB,UAAU,GAAG,SAAS,GAAG,iBAAiB,GAAG,MAAM,CACpD,GACA,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA+EjD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,oBAAoB,mEA6GxD"}
@@ -0,0 +1,15 @@
1
+ import { ValidatorOptions } from './types';
2
+ import * as yup from "yup";
3
+ /**
4
+ * IBAN regex'i (Türkiye için TR ile başlamalı)
5
+ */
6
+ export declare const IBAN_REGEX: RegExp;
7
+ /**
8
+ * IBAN validasyonu (mod 97 algoritması)
9
+ */
10
+ export declare function validateIBAN(iban: string): boolean;
11
+ /**
12
+ * IBAN için yup schema
13
+ */
14
+ export declare function ibanSchema(options?: ValidatorOptions): yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
15
+ //# sourceMappingURL=iban.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iban.d.ts","sourceRoot":"","sources":["../../src/validators/iban.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,UAAU,QAA8C,CAAC;AAEtE;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAsBlD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,gBAAgB,sEAmCpD"}
@@ -0,0 +1,13 @@
1
+ export type { ValidatorOptions, FileValidatorOptions, PasswordValidatorOptions, DateValidatorOptions, } from './types';
2
+ export { tcKimlikNoSchema, TC_KIMLIK_NO_REGEX, validateTCKimlikNo, } from './tcKimlikNo';
3
+ export { emailSchema, EMAIL_REGEX, validateEmail } from './email';
4
+ export { phoneSchema, PHONE_REGEX, validatePhone } from './phone';
5
+ export { passwordSchema, passwordMatchSchema, validatePassword, } from './password';
6
+ export { nameSchema, NAME_REGEX, validateName } from './name';
7
+ export { ibanSchema, IBAN_REGEX, validateIBAN } from './iban';
8
+ export { creditCardSchema, CREDIT_CARD_REGEX, validateCreditCard, } from './creditCard';
9
+ export { vknSchema, VKN_REGEX, validateVKN } from './vkn';
10
+ export { plateSchema, PLATE_REGEX, validatePlate } from './plate';
11
+ export { fileSchema, validateFile, getFileExtension, } from './file';
12
+ export { dateSchema, pastDateSchema, futureDateSchema, validateDate, } from './date';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGlE,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAG9D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAG9D,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGlE,OAAO,EACL,UAAU,EACV,YAAY,EACZ,gBAAgB,GACjB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACL,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,YAAY,GACb,MAAM,QAAQ,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { ValidatorOptions } from './types';
2
+ import * as yup from "yup";
3
+ /**
4
+ * Sadece harf içeren isim regex'i (Türkçe karakterler dahil)
5
+ */
6
+ export declare const NAME_REGEX: RegExp;
7
+ /**
8
+ * İsim validasyonu (sadece harf)
9
+ */
10
+ export declare function validateName(name: string): boolean;
11
+ /**
12
+ * İsim için yup schema
13
+ */
14
+ export declare function nameSchema(options?: ValidatorOptions): yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
15
+ //# sourceMappingURL=name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name.d.ts","sourceRoot":"","sources":["../../src/validators/name.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,UAAU,QAA+B,CAAC;AAEvD;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAWlD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,gBAAgB,sEAsCpD"}
@@ -0,0 +1,18 @@
1
+ import { PasswordValidatorOptions, ValidatorOptions } from './types';
2
+ import * as yup from "yup";
3
+ /**
4
+ * Şifre validasyonu
5
+ */
6
+ export declare function validatePassword(password: string, options?: Omit<PasswordValidatorOptions, "required" | "message" | "requiredMessage" | "name">): {
7
+ isValid: boolean;
8
+ errors: string[];
9
+ };
10
+ /**
11
+ * Şifre için yup schema
12
+ */
13
+ export declare function passwordSchema(options?: PasswordValidatorOptions): yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
14
+ /**
15
+ * Şifre eşleşme kontrolü
16
+ */
17
+ export declare function passwordMatchSchema(passwordFieldName: string, options?: ValidatorOptions): yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
18
+ //# sourceMappingURL=password.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../src/validators/password.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE1E;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,IAAI,CACZ,wBAAwB,EACxB,UAAU,GAAG,SAAS,GAAG,iBAAiB,GAAG,MAAM,CACpD,GACA;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAsCxC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,wBAAwB,sEAiDhE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,iBAAiB,EAAE,MAAM,EACzB,OAAO,CAAC,EAAE,gBAAgB,sEAiB3B"}
@@ -0,0 +1,16 @@
1
+ import { ValidatorOptions } from './types';
2
+ import * as yup from "yup";
3
+ /**
4
+ * Türkiye telefon numarası regex'i
5
+ * Formatlar: 05XX XXX XX XX, +90 5XX XXX XX XX, 5XX XXX XX XX
6
+ */
7
+ export declare const PHONE_REGEX: RegExp;
8
+ /**
9
+ * Telefon numarası validasyonu
10
+ */
11
+ export declare function validatePhone(phone: string): boolean;
12
+ /**
13
+ * Telefon numarası için yup schema
14
+ */
15
+ export declare function phoneSchema(options?: ValidatorOptions): yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
16
+ //# sourceMappingURL=phone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phone.d.ts","sourceRoot":"","sources":["../../src/validators/phone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,WAAW,QACgC,CAAC;AAEzD;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAepD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,gBAAgB,sEAmCrD"}
@@ -0,0 +1,16 @@
1
+ import { ValidatorOptions } from './types';
2
+ import * as yup from "yup";
3
+ /**
4
+ * Türkiye araç plakası regex'i
5
+ * Format: 34 ABC 123 veya 34ABC123
6
+ */
7
+ export declare const PLATE_REGEX: RegExp;
8
+ /**
9
+ * Araç plakası validasyonu
10
+ */
11
+ export declare function validatePlate(plate: string): boolean;
12
+ /**
13
+ * Araç plakası için yup schema
14
+ */
15
+ export declare function plateSchema(options?: ValidatorOptions): yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
16
+ //# sourceMappingURL=plate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plate.d.ts","sourceRoot":"","sources":["../../src/validators/plate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,WAAW,QAAiD,CAAC;AAE1E;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAgCpD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,gBAAgB,sEAmCrD"}
@@ -0,0 +1,57 @@
1
+ import { ValidatorOptions } from './types';
2
+ import * as yup from "yup";
3
+ /**
4
+ * T.C. Kimlik Numarası validasyon regex'i
5
+ * 11 haneli, sadece rakamlardan oluşmalı
6
+ */
7
+ export declare const TC_KIMLIK_NO_REGEX: RegExp;
8
+ /**
9
+ * T.C. Kimlik Numarası algoritma kontrolü
10
+ * T.C. kimlik numarasının geçerliliğini kontrol eder
11
+ */
12
+ export declare function validateTCKimlikNo(tcKimlikNo: string): boolean;
13
+ /**
14
+ * T.C. kimlik numarası için yup schema
15
+ * Zorunluluk dışarıdan belirlenir
16
+ *
17
+ * @param options - Validator seçenekleri
18
+ * @param options.required - Alanın zorunlu olup olmadığı (default: false)
19
+ * @param options.message - Özel hata mesajı
20
+ * @param options.requiredMessage - Required alan için özel hata mesajı
21
+ * @param options.name - Validator test adı (default: 'tcKimlikNo')
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import * as yup from 'yup'
26
+ * import { tcKimlikNoSchema } from '@mertcankocak/core-project'
27
+ *
28
+ * // Optional kullanım
29
+ * const optionalSchema = yup.object({
30
+ * tcKimlikNo: tcKimlikNoSchema()
31
+ * })
32
+ *
33
+ * // Required kullanım
34
+ * const requiredSchema = yup.object({
35
+ * tcKimlikNo: tcKimlikNoSchema({ required: true })
36
+ * })
37
+ *
38
+ * // Özel mesajlarla
39
+ * const customSchema = yup.object({
40
+ * tcKimlikNo: tcKimlikNoSchema({
41
+ * required: true,
42
+ * message: 'Geçersiz T.C. kimlik numarası',
43
+ * requiredMessage: 'T.C. kimlik numarası boş bırakılamaz'
44
+ * })
45
+ * })
46
+ *
47
+ * // Özel name ile
48
+ * const customNameSchema = yup.object({
49
+ * userTCNo: tcKimlikNoSchema({
50
+ * name: 'userTCNo',
51
+ * required: true
52
+ * })
53
+ * })
54
+ * ```
55
+ */
56
+ export declare function tcKimlikNoSchema(options?: ValidatorOptions): yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
57
+ //# sourceMappingURL=tcKimlikNo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tcKimlikNo.d.ts","sourceRoot":"","sources":["../../src/validators/tcKimlikNo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAgB,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAyB9D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,gBAAgB,sEA8C1D"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Validator seçenekleri
3
+ * Tüm validatörler için ortak seçenekler
4
+ */
5
+ export interface ValidatorOptions {
6
+ /**
7
+ * Alanın zorunlu olup olmadığı
8
+ * @default false (optional)
9
+ */
10
+ required?: boolean;
11
+ /**
12
+ * Özel hata mesajı
13
+ */
14
+ message?: string;
15
+ /**
16
+ * Required alan için özel hata mesajı
17
+ */
18
+ requiredMessage?: string;
19
+ /**
20
+ * Validator test adı (yup test name)
21
+ */
22
+ name?: string;
23
+ }
24
+ /**
25
+ * Dosya validasyon seçenekleri
26
+ *
27
+ * ÖNEMLİ: Güvenlik için mutlaka 'allowedMimeTypes' kullanın!
28
+ *
29
+ * Dosya uzantısı kontrolü tek başına yeterli değildir çünkü:
30
+ * - Birisi bir .exe dosyasını .pdf olarak adlandırabilir
31
+ * - Birisi bir virüslü dosyayı .jpg olarak adlandırabilir
32
+ *
33
+ * 'allowedMimeTypes' parametresi magic bytes kontrolü yapar:
34
+ * - Dosyanın içeriğinin ilk byte'larına bakarak gerçek tipini belirler
35
+ * - Örnek: PDF dosyası %PDF- ile başlar, JPEG FF D8 FF ile başlar
36
+ * - Bu sayede dosya adı ne olursa olsun, gerçek tipi tespit edilir
37
+ */
38
+ export interface FileValidatorOptions extends ValidatorOptions {
39
+ /**
40
+ * Maksimum dosya boyutu (byte cinsinden)
41
+ */
42
+ maxSize?: number;
43
+ /**
44
+ * Minimum dosya boyutu (byte cinsinden)
45
+ */
46
+ minSize?: number;
47
+ /**
48
+ * İzin verilen dosya uzantıları (örn: ['pdf', 'jpg', 'png'])
49
+ *
50
+ * ⚠️ UYARI: Bu kontrol tek başına güvenli değildir!
51
+ * Mutlaka 'allowedMimeTypes' ile birlikte kullanın.
52
+ */
53
+ allowedExtensions?: string[];
54
+ /**
55
+ * İzin verilen MIME tipleri (örn: ['application/pdf', 'image/jpeg'])
56
+ *
57
+ * ✅ ÖNERİLEN: Magic bytes kontrolü yapar, gerçek dosya tipini belirler.
58
+ * Bu parametre belirtilmezse sadece uzantı kontrolü yapılır (güvenli değil).
59
+ *
60
+ * Yaygın MIME tipleri:
61
+ * - PDF: 'application/pdf'
62
+ * - JPEG: 'image/jpeg'
63
+ * - PNG: 'image/png'
64
+ * - GIF: 'image/gif'
65
+ * - ZIP: 'application/zip'
66
+ * - DOCX: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
67
+ */
68
+ allowedMimeTypes?: string[];
69
+ /**
70
+ * Dosya boyutu için özel hata mesajı
71
+ */
72
+ sizeMessage?: string;
73
+ /**
74
+ * Dosya uzantısı için özel hata mesajı
75
+ */
76
+ extensionMessage?: string;
77
+ }
78
+ /**
79
+ * Şifre validasyon seçenekleri
80
+ */
81
+ export interface PasswordValidatorOptions extends ValidatorOptions {
82
+ /**
83
+ * Minimum şifre uzunluğu
84
+ * @default 8
85
+ */
86
+ minLength?: number;
87
+ /**
88
+ * Büyük harf gereksinimi
89
+ * @default true
90
+ */
91
+ requireUppercase?: boolean;
92
+ /**
93
+ * Küçük harf gereksinimi
94
+ * @default true
95
+ */
96
+ requireLowercase?: boolean;
97
+ /**
98
+ * Rakam gereksinimi
99
+ * @default true
100
+ */
101
+ requireNumber?: boolean;
102
+ /**
103
+ * Özel karakter gereksinimi
104
+ * @default true
105
+ */
106
+ requireSpecialChar?: boolean;
107
+ /**
108
+ * Minimum uzunluk için özel hata mesajı
109
+ */
110
+ minLengthMessage?: string;
111
+ /**
112
+ * Büyük harf için özel hata mesajı
113
+ */
114
+ uppercaseMessage?: string;
115
+ /**
116
+ * Küçük harf için özel hata mesajı
117
+ */
118
+ lowercaseMessage?: string;
119
+ /**
120
+ * Rakam için özel hata mesajı
121
+ */
122
+ numberMessage?: string;
123
+ /**
124
+ * Özel karakter için özel hata mesajı
125
+ */
126
+ specialCharMessage?: string;
127
+ }
128
+ /**
129
+ * Tarih validasyon seçenekleri
130
+ */
131
+ export interface DateValidatorOptions extends ValidatorOptions {
132
+ /**
133
+ * Minimum tarih (geçmiş tarih kontrolü)
134
+ */
135
+ minDate?: Date | string;
136
+ /**
137
+ * Maksimum tarih (gelecek tarih kontrolü)
138
+ */
139
+ maxDate?: Date | string;
140
+ /**
141
+ * Minimum tarih için özel hata mesajı
142
+ */
143
+ minDateMessage?: string;
144
+ /**
145
+ * Maksimum tarih için özel hata mesajı
146
+ */
147
+ maxDateMessage?: string;
148
+ }
149
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/validators/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB;IAChE;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D;;OAEG;IACH,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACxB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,16 @@
1
+ import { ValidatorOptions } from './types';
2
+ import * as yup from "yup";
3
+ /**
4
+ * VKN (Vergi Kimlik Numarası) regex'i
5
+ * 10 haneli rakam
6
+ */
7
+ export declare const VKN_REGEX: RegExp;
8
+ /**
9
+ * VKN validasyonu
10
+ */
11
+ export declare function validateVKN(vkn: string): boolean;
12
+ /**
13
+ * VKN için yup schema
14
+ */
15
+ export declare function vknSchema(options?: ValidatorOptions): yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
16
+ //# sourceMappingURL=vkn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vkn.d.ts","sourceRoot":"","sources":["../../src/validators/vkn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,SAAS,QAAa,CAAC;AAEpC;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAgBhD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB,sEAmCnD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mertcankocak/core-project",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "React TypeScript component library built with Vite",
5
5
  "type": "module",
6
6
  "main": "./dist/core-project.umd.js",
@@ -31,9 +31,19 @@
31
31
  ],
32
32
  "author": "",
33
33
  "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/MertcanKocak1/CoreProject.git"
37
+ },
38
+ "bugs": {
39
+ "url": "https://github.com/MertcanKocak1/CoreProject/issues"
40
+ },
41
+ "homepage": "https://github.com/MertcanKocak1/CoreProject#readme",
34
42
  "peerDependencies": {
35
43
  "react": "^18.0.0",
36
- "react-dom": "^18.0.0"
44
+ "react-dom": "^18.0.0",
45
+ "yup": "^1.0.0",
46
+ "file-type": "^19.0.0"
37
47
  },
38
48
  "devDependencies": {
39
49
  "@types/react": "^18.2.43",
@@ -43,6 +53,8 @@
43
53
  "react-dom": "^18.2.0",
44
54
  "typescript": "^5.3.3",
45
55
  "vite": "^5.0.8",
46
- "vite-plugin-dts": "^3.6.4"
56
+ "vite-plugin-dts": "^3.6.4",
57
+ "yup": "^1.4.0",
58
+ "file-type": "^19.0.0"
47
59
  }
48
60
  }