diff --git a/lib/main/patterns-functions.ts b/lib/main/patterns-functions.ts index cf39c37..a0542e0 100644 --- a/lib/main/patterns-functions.ts +++ b/lib/main/patterns-functions.ts @@ -163,3 +163,14 @@ export const isStreetPattern = (value: string): boolean => { * @param {string} value - value to check. * @returns {boolean} */ + +export const isPolishStreetPattern = (value: string): boolean => { + const pattern = '[a-zA-Z\\u00C0-\\u017F]+\\s\\d.*$' + return !!value.match(pattern) +} +/** + * Checks if value matches pattern + *
 /[a-zA-Z\\u00C0-\\u017F]+\\s\\d.*$/ 
+ * @param {string} value - value to check. + * @returns {boolean} + */ diff --git a/test/patterns-functions.spec.ts b/test/patterns-functions.spec.ts index 7c6c250..43b9fbf 100644 --- a/test/patterns-functions.spec.ts +++ b/test/patterns-functions.spec.ts @@ -10,7 +10,7 @@ import { isNamePattern, isNipPattern, isNumericPattern, - isPasswordPattern, + isPasswordPattern, isPolishStreetPattern, isPostalCodePattern, isStreetPattern, } from '../lib' @@ -134,4 +134,14 @@ describe('pattern functions', () => { expect(isStreetPattern('Pyk?')).toBeFalsy() expect(isStreetPattern('*Cyk*Cyk*Cyk*')).toBeFalsy() }) + + it('isPolishStreetPattern should validate correctly', () => { + expect(isPolishStreetPattern('Klonowa 32')).toBeTruthy() + expect(isPolishStreetPattern('klonowa 32')).toBeTruthy() + expect(isPolishStreetPattern('KLONOWA 32')).toBeTruthy() + expect(isPolishStreetPattern('ul. KlonowaƂ 32')).toBeTruthy() + expect(isPolishStreetPattern('32 Klonowa')).toBeFalsy() + expect(isPolishStreetPattern('Klonowa')).toBeFalsy() + expect(isPolishStreetPattern('32')).toBeFalsy() + }) })