Skip to content

Commit

Permalink
[FAGSYSTEM-308734] Legge til sjekk på at meldinger inneholder non-whi…
Browse files Browse the repository at this point in the history
…tespace char
  • Loading branch information
Jesperpaulsen committed Dec 12, 2023
1 parent b3a548b commit a0393e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/app/personside/dialogpanel/fortsettDialog/validatorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FortsettDialogState } from './FortsettDialogTypes';

export class FortsettDialogValidator {
public static tekst(state: FortsettDialogState) {
return state.tekst.length <= tekstMaksLengde && state.tekst.length > 0;
return state.tekst.length <= tekstMaksLengde && state.tekst.length > 0 && this.inneholderTekst(state);
}
public static sak(state: FortsettDialogState) {
return state.sak !== undefined;
Expand All @@ -18,4 +18,8 @@ export class FortsettDialogValidator {
public static erGyldigSamtalereferat(state: FortsettDialogState) {
return state.traadType === TraadType.SAMTALEREFERAT && this.tekst(state);
}
private static inneholderTekst(state: FortsettDialogState) {
const ikkeTekst = /\S/g
return !!state.tekst.match(ikkeTekst)
}
}
7 changes: 6 additions & 1 deletion src/app/personside/dialogpanel/sendMelding/validatorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TraadType } from '../../../../models/meldinger/meldinger';

export class MeldingValidator {
public static tekst(state: SendNyMeldingState) {
return state.tekst.length <= tekstMaksLengde && state.tekst.length > 0;
return state.tekst.length <= tekstMaksLengde && state.tekst.length > 0 && this.inneholderTekst(state);
}
public static tema(state: SendNyMeldingState) {
return state.tema !== undefined;
Expand All @@ -23,4 +23,9 @@ export class MeldingValidator {
public static erGyldigSamtale(state: SendNyMeldingState) {
return this.erSamtale(state) && this.sak(state) && this.tekst(state);
}

private static inneholderTekst(state: SendNyMeldingState) {
const ikkeTekst = /\S/g
return !!state.tekst.match(ikkeTekst)
}
}

0 comments on commit a0393e8

Please sign in to comment.