Download benchmarks/javascript/validators.js from SevdanurGenc/LLM-Automated-Test-Generation-Agent: direct link, hf CLI and curl.
- Browser
- Download file 1.83 kB
-
https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/javascript/validators.js
- Command line
-
hf download hf://SevdanurGenc/LLM-Automated-Test-Generation-Agent/benchmarks/javascript/validators.js
-
curl -L -o validators.js https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/javascript/validators.js
1.83 kB
| /** Form doğrulayıcıları. */ | |
| function isValidEmail(email) { | |
| if (typeof email !== 'string') return false; | |
| const re = /^[^\s@]+@[^\s@]+\.[a-z]{2,}$/i; | |
| return re.test(email.trim()); | |
| } | |
| /** Parola gücü: 0 (çok zayıf) - 4 (güçlü). */ | |
| function passwordStrength(pw) { | |
| if (typeof pw !== 'string' || pw.length === 0) return 0; | |
| let score = 0; | |
| if (pw.length >= 8) score++; | |
| if (/[a-z]/.test(pw) && /[A-Z]/.test(pw)) score++; | |
| if (/\d/.test(pw)) score++; | |
| if (/[^A-Za-z0-9]/.test(pw)) score++; | |
| if (pw.length < 6) score = Math.min(score, 1); | |
| return score; | |
| } | |
| /** | |
| * T.C. Kimlik No doğrulaması: | |
| * - 11 hane, ilk hane 0 olamaz | |
| * - 10. hane = ((tekler toplamı * 7) - çiftler toplamı) mod 10 | |
| * - 11. hane = ilk 10 hanenin toplamı mod 10 | |
| */ | |
| function isValidTCKN(value) { | |
| const s = String(value); | |
| if (!/^\d{11}$/.test(s) || s[0] === '0') return false; | |
| const d = s.split('').map(Number); | |
| const odd = d[0] + d[2] + d[4] + d[6] + d[8]; | |
| const even = d[1] + d[3] + d[5] + d[7]; | |
| const d10 = (((odd * 7 - even) % 10) + 10) % 10; | |
| if (d10 !== d[9]) return false; | |
| const sum10 = d.slice(0, 10).reduce((a, b) => a + b, 0); | |
| return sum10 % 10 === d[10]; | |
| } | |
| /** Türk cep telefonu: 05xx xxx xx xx, +90 5xx..., 5xx... biçimlerini normalize eder. */ | |
| function normalizePhone(input) { | |
| const digits = String(input).replace(/\D/g, ''); | |
| let local; | |
| if (digits.length === 12 && digits.startsWith('90')) local = digits.slice(2); | |
| else if (digits.length === 11 && digits.startsWith('0')) local = digits.slice(1); | |
| else if (digits.length === 10) local = digits; | |
| else return null; | |
| if (local[0] !== '5') return null; | |
| return `+90 ${local.slice(0, 3)} ${local.slice(3, 6)} ${local.slice(6, 8)} ${local.slice(8)}`; | |
| } | |
| module.exports = { isValidEmail, passwordStrength, isValidTCKN, normalizePhone }; | |