File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
frontend/src/components/Topics/Topic/Messages Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { InputLabel } from 'components/common/Input/InputLabel.styled';
66import IconButtonWrapper from 'components/common/Icons/IconButtonWrapper' ;
77import EditIcon from 'components/common/Icons/EditIcon' ;
88import CancelIcon from 'components/common/Icons/CancelIcon' ;
9+ import { JSONPath } from 'jsonpath-plus' ;
910
1011import * as S from './PreviewModal.styled' ;
1112import { PreviewFilter } from './Message' ;
@@ -33,8 +34,14 @@ const PreviewModal: React.FC<InfoModalProps> = ({
3334 newErrors . push ( 'field' ) ;
3435 }
3536
36- if ( path === '' ) {
37+ if ( path . trim ( ) === '' ) {
3738 newErrors . push ( 'path' ) ;
39+ } else {
40+ try {
41+ JSONPath ( { path, json : { } } ) ;
42+ } catch {
43+ newErrors . push ( 'invalidPath' ) ;
44+ }
3845 }
3946
4047 if ( newErrors ?. length ) {
@@ -111,6 +118,7 @@ const PreviewModal: React.FC<InfoModalProps> = ({
111118 />
112119 < FormError >
113120 { errors . includes ( 'path' ) && 'Json path is required' }
121+ { errors . includes ( 'invalidPath' ) && 'Invalid JSONPath syntax' }
114122 </ FormError >
115123 </ div >
116124 < S . ButtonWrapper >
You can’t perform that action at this time.
0 commit comments