File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Script Includes/Validate Data Before Insert Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ var DataValidationUtils = Class . create ( ) ;
2
+ DataValidationUtils . prototype = {
3
+ initialize : function ( ) { } ,
4
+
5
+ validateIncidentData : function ( incidentRecord ) {
6
+ var errors = [ ] ;
7
+
8
+ // Validate short description if the field exists
9
+ if ( incidentRecord . isValidField ( 'short_description' ) ) {
10
+ if ( gs . nil ( incidentRecord . short_description ) ) {
11
+ errors . push ( 'Short description is required.' ) ;
12
+ }
13
+ } else {
14
+ errors . push ( 'Field "short_description" does not exist on the record.' ) ;
15
+ }
16
+
17
+ // Validate priority if the field exists
18
+ if ( incidentRecord . isValidField ( 'priority' ) ) {
19
+ if ( gs . nil ( incidentRecord . priority ) || incidentRecord . priority < 1 || incidentRecord . priority > 5 ) {
20
+ errors . push ( 'Priority must be between 1 and 5.' ) ;
21
+ }
22
+ } else {
23
+ errors . push ( 'Field "priority" does not exist on the record.' ) ;
24
+ }
25
+
26
+ return errors ;
27
+ } ,
28
+
29
+ type : 'DataValidationUtils'
30
+ } ;
You can’t perform that action at this time.
0 commit comments