File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
src/vfjs-global-mixin/methods/vfjs-validation Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,19 @@ const vfjsValidationGetters = {
106106
107107 if ( isRequired ) {
108108 set ( schema , required , [ path ] ) ;
109+
110+ // IF ajv-errors plugin is present (errorMessage keyword is added)
111+ // AND fieldSchema has a custom errorMessage definition:
112+ // THEN add that errorMessage one level up in the schema's hierarchy
113+ // (right next to where the required fields are defined)
114+ // so that ajv can handle this properly with the ajv-errors plugin
115+ if ( this . ajv . RULES . keywords . errorMessage && fieldSchema . errorMessage ) {
116+ const errorMessagePath = previousPaths . length > 0
117+ ? `${ previousProperties } .errorMessage`
118+ : 'errorMessage' ;
119+
120+ set ( schema , errorMessagePath , fieldSchema . errorMessage ) ;
121+ }
109122 }
110123 } else {
111124 set ( schema , properties , { } ) ;
You can’t perform that action at this time.
0 commit comments