File tree 2 files changed +2
-26
lines changed
apps/omsorgspengesoknad/src/app/søknad/steps/om-barnet/spørsmål
packages/sif-validation/src
2 files changed +2
-26
lines changed Original file line number Diff line number Diff line change @@ -18,16 +18,13 @@ const HøyereRisikoForFraværBeskrivelseSpørsmål = () => {
18
18
return (
19
19
< Textarea
20
20
name = { OmBarnetFormFields . høyereRisikoForFraværBeskrivelse }
21
- validate = { async ( value ) => {
21
+ validate = { ( value ) => {
22
22
const error = getStringValidator ( {
23
23
required : true ,
24
24
minLength : 5 ,
25
25
maxLength : 1000 ,
26
- noUnicodeCharacters : true ,
27
26
} ) ( value ) ;
28
- if ( error ) {
29
- return error ;
30
- }
27
+ return error ;
31
28
} }
32
29
maxLength = { 1000 }
33
30
label = { text ( 'steg.omBarnet.spm.høyereRisikoForFraværBeskrivelse.label' ) }
Original file line number Diff line number Diff line change @@ -28,29 +28,13 @@ interface Options {
28
28
minLength ?: number ;
29
29
maxLength ?: number ;
30
30
formatRegExp ?: RegExp ;
31
- noUnicodeCharacters ?: boolean ;
32
- /** Deprecated */
33
31
disallowUnicodeCharacters ?: boolean ;
34
32
}
35
33
36
34
const containsNonLatinCodepoints = ( s : string ) : boolean => {
37
35
return / [ ^ u 0 0 0 0 - \u00ff \s ] / . test ( s ) ;
38
36
} ;
39
37
40
- const containsUnwantedCharacters = ( s : string ) : boolean => {
41
- return / [ ^ \p{ L} \p{ N} \p{ P} \p{ Z} \p{ M} « » § \n \r ~ ] / gu. test ( s ) ;
42
- // return /^[\p{L}\p{N}\p{P}\p{Z}\p{M}«»§]+$/u.test(s) === false; // /^[A-Za-z0-9\u00C0-\u024F\u1E00-\u1EFF\s\p{Pd}\p{Ps}\p{Pe}«»"§]+$/u.test(s) === false;
43
- } ;
44
-
45
- const supportsUnicodeRegex = ( ( ) => {
46
- try {
47
- new RegExp ( '\\p{L}' , 'u' ) ;
48
- return true ;
49
- } catch {
50
- return false ;
51
- }
52
- } ) ( ) ;
53
-
54
38
const getStringValidator =
55
39
( options : Options = { } ) : ValidationFunction < StringValidationResult > =>
56
40
( value : any ) => {
@@ -77,11 +61,6 @@ const getStringValidator =
77
61
return ValidateStringError . stringHasInvalidFormat ;
78
62
}
79
63
}
80
- if ( options . noUnicodeCharacters ) {
81
- if ( supportsUnicodeRegex && containsUnwantedCharacters ( value ) ) {
82
- return ValidateStringError . stringContainsUnicodeChacters ;
83
- }
84
- }
85
64
if ( options . disallowUnicodeCharacters ) {
86
65
if ( containsNonLatinCodepoints ( value ) ) {
87
66
return ValidateStringError . stringContainsUnicodeChacters ;
You can’t perform that action at this time.
0 commit comments