From 3ad762f0e584671883dae6eef22af64c58032922 Mon Sep 17 00:00:00 2001 From: Matheus Gome Date: Wed, 19 Jun 2019 17:28:53 -0300 Subject: [PATCH 1/2] New validators for key text Signed-off-by: Matheus Gome --- projects/justa/br-validators/package.json | 2 +- .../br-validators/src/validators/index.ts | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/projects/justa/br-validators/package.json b/projects/justa/br-validators/package.json index ba110f0..2d8304a 100644 --- a/projects/justa/br-validators/package.json +++ b/projects/justa/br-validators/package.json @@ -1,6 +1,6 @@ { "name": "@justa/ng-validators", - "version": "1.0.0", + "version": "0.2.0", "peerDependencies": { "@angular/common": "^5.0.0 || ^6.0.0 || ^7.0.0", "@angular/core": "^5.0.0 || ^6.0.0 || ^7.0.0", diff --git a/projects/justa/br-validators/src/validators/index.ts b/projects/justa/br-validators/src/validators/index.ts index d983f5e..21e0ac4 100644 --- a/projects/justa/br-validators/src/validators/index.ts +++ b/projects/justa/br-validators/src/validators/index.ts @@ -74,10 +74,27 @@ function validateURL(control: AbstractControl): ValidationErrors | null { : null; } +/** + * @description Provide a validator for key text that do not accept special characters or spaces + */ +function validateTextKey(control: AbstractControl): ValidationErrors | null { + const controlValue = control.value; + const pattern = /([\u00C0-\u00FF ])/g; + return controlValue.match(pattern) + ? { + isInvalid: { + expected: true, + message: "Não é permitido caracteres especiais ou espaços neste campo" + } + } + : null; +} + export const jstValidators = { validateDate, validateCNPJ, validateCPF, validatePhone, - validateURL + validateURL, + validateTextKey }; From 11796d14932c678fff306e75d50b0c56fae92dbf Mon Sep 17 00:00:00 2001 From: Matheus Gome Date: Thu, 20 Jun 2019 09:15:35 -0300 Subject: [PATCH 2/2] Version update Signed-off-by: Matheus Gome --- projects/justa/br-validators/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/justa/br-validators/package.json b/projects/justa/br-validators/package.json index 2d8304a..adff5fd 100644 --- a/projects/justa/br-validators/package.json +++ b/projects/justa/br-validators/package.json @@ -1,6 +1,6 @@ { "name": "@justa/ng-validators", - "version": "0.2.0", + "version": "1.1.0", "peerDependencies": { "@angular/common": "^5.0.0 || ^6.0.0 || ^7.0.0", "@angular/core": "^5.0.0 || ^6.0.0 || ^7.0.0",