feat(regex): backend validations on regex strings
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
@file
|
||||
@brief migration script to move to v7.11 of Data Controller
|
||||
|
||||
OPTIONAL CHANGE - upload additional validation rules (HARDREGEX, SOFTREGEX)
|
||||
into the RULE_TYPE dropdown (data only)
|
||||
|
||||
**/
|
||||
|
||||
%let dclib=YOURDCLIB;
|
||||
|
||||
libname &dclib "/YOUR/DATACONTROLLER/LIBRARY/PATH";
|
||||
|
||||
|
||||
/* add new validation rules */
|
||||
proc sql noprint;
|
||||
select max(selectbox_rk) into: maxrk
|
||||
from &dclib..mpe_selectbox;
|
||||
insert into &dclib..mpe_selectbox set
|
||||
selectbox_rk=&maxrk+1
|
||||
,ver_from_dttm=0
|
||||
,select_lib="&dclib"
|
||||
,select_ds="MPE_VALIDATIONS"
|
||||
,base_column="RULE_TYPE"
|
||||
,selectbox_value='HARDREGEX'
|
||||
,selectbox_order=13
|
||||
,ver_to_dttm='31DEC5999:23:59:59'dt;
|
||||
insert into &dclib..mpe_selectbox set
|
||||
selectbox_rk=&maxrk+2
|
||||
,ver_from_dttm=0
|
||||
,select_lib="&dclib"
|
||||
,select_ds="MPE_VALIDATIONS"
|
||||
,base_column="RULE_TYPE"
|
||||
,selectbox_value='SOFTREGEX'
|
||||
,selectbox_order=14
|
||||
,ver_to_dttm='31DEC5999:23:59:59'dt;
|
||||
quit;
|
||||
@@ -916,6 +916,24 @@ insert into &lib..mpe_selectbox set
|
||||
,selectbox_value="SOFTSELECT_HOOK"
|
||||
,selectbox_order=12
|
||||
,ver_to_dttm='31DEC5999:23:59:59'dt;
|
||||
insert into &lib..mpe_selectbox set
|
||||
selectbox_rk=%mf_increment(rk)
|
||||
,ver_from_dttm=0
|
||||
,select_lib="&lib"
|
||||
,select_ds="MPE_VALIDATIONS"
|
||||
,base_column="RULE_TYPE"
|
||||
,selectbox_value="HARDREGEX"
|
||||
,selectbox_order=13
|
||||
,ver_to_dttm='31DEC5999:23:59:59'dt;
|
||||
insert into &lib..mpe_selectbox set
|
||||
selectbox_rk=%mf_increment(rk)
|
||||
,ver_from_dttm=0
|
||||
,select_lib="&lib"
|
||||
,select_ds="MPE_VALIDATIONS"
|
||||
,base_column="RULE_TYPE"
|
||||
,selectbox_value="SOFTREGEX"
|
||||
,selectbox_order=14
|
||||
,ver_to_dttm='31DEC5999:23:59:59'dt;
|
||||
insert into &lib..mpe_selectbox set
|
||||
selectbox_rk=%mf_increment(rk)
|
||||
,ver_from_dttm=0
|
||||
|
||||
@@ -70,3 +70,38 @@ run;
|
||||
,msg=%str(The following vars have duplicate HOOKS: &src_list2)
|
||||
)
|
||||
|
||||
|
||||
/** check that any supplied HARDREGEX / SOFTREGEX rules contain a valid
|
||||
regex pattern. The frontend evaluates these as JavaScript regexes
|
||||
(invalid ones are silently ignored there), so prxparse is used here as
|
||||
a best-effort syntax check to catch typos at config time.
|
||||
An empty pattern is treated as valid (matches everything in JS). */
|
||||
data work.regex_check;
|
||||
length source $74;
|
||||
set work.staging_ds(
|
||||
where=(rule_type in ('HARDREGEX','SOFTREGEX')
|
||||
and upcase(_____DELETE__THIS__RECORD_____) ne "YES")
|
||||
);
|
||||
keep source rule_value;
|
||||
if rule_value ne ' ' then do;
|
||||
rx=prxparse(strip(rule_value));
|
||||
if missing(rx) then do;
|
||||
source=catx('.',base_lib,base_ds,base_col);
|
||||
output;
|
||||
end;
|
||||
else call prxfree(rx);
|
||||
end;
|
||||
run;
|
||||
|
||||
%global src_list3;
|
||||
%let src_list3='';
|
||||
proc sql noprint;
|
||||
select distinct quote(cats(source)) into: src_list3 separated by ','
|
||||
from work.regex_check;
|
||||
quit;
|
||||
|
||||
%mp_abort(iftrue= (%mf_nobs(work.regex_check)>0)
|
||||
,mac=mpe_validations_postedit
|
||||
,msg=%str(The following vars have invalid REGEX patterns: &src_list3)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user