@@ -1029,24 +1029,6 @@ export class ExpressionFunctions {
10291029 }
10301030 }
10311031
1032- private static canBeModified ( value : any , property : string , expected ?: number ) : boolean {
1033- let modifiable = false ;
1034- if ( expected !== undefined ) {
1035- // Modifiable list
1036- modifiable = Array . isArray ( value ) ;
1037- } else {
1038- // Modifiable object
1039- modifiable = value instanceof Map ;
1040- if ( ! modifiable ) {
1041- if ( typeof value === 'object' ) {
1042- modifiable = value . hasOwnProperty ( property ) ;
1043- }
1044- }
1045- }
1046-
1047- return modifiable ;
1048- }
1049-
10501032 private static setPathToValue ( expression : Expression , state : MemoryInterface ) : { value : any ; error : string } {
10511033 let path : string ;
10521034 let left : Expression ;
@@ -2985,12 +2967,18 @@ export class ExpressionFunctions {
29852967 ( expression : Expression ) : void => ExpressionFunctions . validateOrder ( expression , undefined , ReturnType . String ) ) ,
29862968 new ExpressionEvaluator (
29872969 ExpressionType . AddProperty ,
2988- ExpressionFunctions . apply (
2970+ ExpressionFunctions . applyWithError (
29892971 ( args : any [ ] ) : any => {
2972+ let error : string ;
29902973 const temp : any = args [ 0 ] ;
2991- temp [ String ( args [ 1 ] ) ] = args [ 2 ] ;
2974+ const prop = String ( args [ 1 ] ) ;
2975+ if ( prop in temp ) {
2976+ error = `${ prop } already exists` ;
2977+ } else {
2978+ temp [ String ( args [ 1 ] ) ] = args [ 2 ] ;
2979+ }
29922980
2993- return temp ;
2981+ return { value : temp , error } ;
29942982 } ) ,
29952983 ReturnType . Object ,
29962984 ( expression : Expression ) : void => ExpressionFunctions . validateOrder ( expression , undefined , ReturnType . Object , ReturnType . String , ReturnType . Object ) ) ,
@@ -3056,12 +3044,12 @@ export class ExpressionFunctions {
30563044 value = false ;
30573045 error = 'regular expression is empty.' ;
30583046 } else {
3059- const regex : RegExp = CommonRegex . CreateRegex ( args [ 1 ] ) ;
3047+ const regex : RegExp = CommonRegex . CreateRegex ( args [ 1 ] . toString ( ) ) ;
30603048 value = regex . test ( args [ 0 ] . toString ( ) ) ;
30613049 }
30623050
30633051 return { value, error} ;
3064- } ) ,
3052+ } , ExpressionFunctions . verifyStringOrNull ) ,
30653053 ReturnType . Boolean ,
30663054 ExpressionFunctions . validateIsMatch ) ,
30673055
0 commit comments