Skip to content

Commit

Permalink
Merge pull request #54 from Currency-One/IKWT-4720
Browse files Browse the repository at this point in the history
Ikwt 4720
  • Loading branch information
HiddeRpl authored Jan 16, 2024
2 parents 9a5e1f3 + 725b933 commit d1a9ad2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
13 changes: 13 additions & 0 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ or matches any math symbols, currency signs, dingbats, box-drawing characters, e
* [.isCharsCompanyPattern](#module_Patterns.isCharsCompanyPattern) ⇒ <code>boolean</code>
* [.isPostalCodePattern](#module_Patterns.isPostalCodePattern) ⇒ <code>boolean</code>
* [.isStreetPattern](#module_Patterns.isStreetPattern) ⇒ <code>boolean</code>
* [.isPolishStreetPattern](#module_Patterns.isPolishStreetPattern) ⇒ <code>boolean</code>

<a name="module_Patterns.isAccountNumberPattern"></a>

Expand Down Expand Up @@ -671,6 +672,18 @@ or matches any math symbols, currency signs, dingbats, box-drawing characters, e
| --- | --- | --- |
| value | <code>string</code> | <p>value to check.</p> |

<a name="module_Patterns.isPolishStreetPattern"></a>

### Patterns.isPolishStreetPattern ⇒ <code>boolean</code>
<p>Checks if value matches <street><number> pattern</p>
<pre> /[a-zA-Z\\u00C0-\\u017F]+\\s\\d.*$/ </pre>

**Kind**: static property of [<code>Patterns</code>](#module_Patterns)

| Param | Type | Description |
| --- | --- | --- |
| value | <code>string</code> | <p>value to check.</p> |

<a name="module_Pesel Validators"></a>

## Pesel Validators
Expand Down
11 changes: 11 additions & 0 deletions lib/main/patterns-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <street><number> pattern
* <pre> /[a-zA-Z\\u00C0-\\u017F]+\\s\\d.*$/ </pre>
* @param {string} value - value to check.
* @returns {boolean}
*/
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@currency-one/validators",
"version": "1.1.22",
"version": "1.1.23",
"description": "Typescript collection of validators and regexp patterns",
"main": "./index.js",
"types": "./index.d.ts",
Expand Down
11 changes: 11 additions & 0 deletions test/patterns-functions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
isNipPattern,
isNumericPattern,
isPasswordPattern,
isPolishStreetPattern,
isPostalCodePattern,
isStreetPattern,
} from '../lib'
Expand Down Expand Up @@ -134,4 +135,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()
})
})

0 comments on commit d1a9ad2

Please sign in to comment.