Skip to content

Commit d8d2568

Browse files
mateusjmafjhonyeduardo
authored andcommitted
fix(decimal): impede a digitação de valores inválidos
Os caracteres de cedilha, colchetes, chaves, interrogação, exclamação, crase, sinal de menor e maior não eram verificados no método responsável, por isso foram inclusos no método responsável pela validação para que o componente não aceite-os. Fixes DTHFUI-914
1 parent c9baac4 commit d8d2568

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

projects/ui/src/lib/components/po-field/po-decimal/po-decimal.component.spec.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,6 @@ describe('PoDecimalComponent:', () => {
105105
expect(component.hasInvalidClass.call(fakeThis)).toBeTruthy();
106106
});
107107

108-
it('should return true in hasLetters', () => {
109-
expect(component.hasLetters('AAAAAA')).toBeTruthy();
110-
});
111-
112-
it('should return true in hasLetters with undefined param', () => {
113-
expect(component.hasLetters(undefined)).toBeFalsy();
114-
});
115-
116108
it('blur event must be called', () => {
117109
const fakeEvent = {
118110
target: {
@@ -1199,6 +1191,23 @@ describe('PoDecimalComponent:', () => {
11991191
expect(component['setViewValue']).not.toHaveBeenCalled();
12001192
expect(component['setCursorInput']).not.toHaveBeenCalled();
12011193
});
1194+
1195+
it('hasLetters: should return true with numbers.', () => {
1196+
expect(component.hasLetters('333')).toBeFalsy();
1197+
});
1198+
1199+
it('hasLetters: should return true wird letters.', () => {
1200+
expect(component.hasLetters('AAAAAA')).toBeTruthy();
1201+
});
1202+
1203+
it('hasLetters: should return true with special characteres.', () => {
1204+
expect(component.hasLetters('!@#$%&')).toBeTruthy();
1205+
});
1206+
1207+
it('hasLetters: should return true with undefined value.', () => {
1208+
expect(component.hasLetters(undefined)).toBeFalsy();
1209+
});
1210+
12021211
});
12031212

12041213
describe('Templates:', () => {

projects/ui/src/lib/components/po-field/po-decimal/po-decimal.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export class PoDecimalComponent extends PoInputBaseComponent implements AfterVie
149149
}
150150

151151
hasLetters(value: string = '') {
152-
return value.match(/[a-zA-Z:;+=_´^~"'@#$%¨&*()/\\|]+/);
152+
return value.match(/[a-zA-Z:;+=_´`^~"'?!@#$%¨&*()><{}çÇ\[\]/\\|]+/);
153153
}
154154

155155
isValidNumber(event: any): boolean {

0 commit comments

Comments
 (0)