File tree Expand file tree Collapse file tree 4 files changed +19
-19
lines changed
demo/src/index/views/Demo/schemaTypes/7.OneOf
fields/combiningSchemas/SelectLinkageField Expand file tree Collapse file tree 4 files changed +19
-19
lines changed Original file line number Diff line number Diff line change @@ -177,17 +177,5 @@ export default {
177177 ]
178178 } ,
179179 errorSchema : {
180- age : {
181- 'err:options' : {
182- oneOf : 'oneOf (oneOf配置)' ,
183- multipleOf : 'multipleOf (上层options配置)' ,
184- required : 'multipleOf (上层options配置)' ,
185- } ,
186- oneOf : [ {
187- 'err:multipleOf' : 'multipleOf (errorSchema配置)'
188- } , {
189- 'err:required' : 'required (errorSchema配置)' ,
190- } ]
191- } ,
192180 }
193181} ;
Original file line number Diff line number Diff line change @@ -180,17 +180,20 @@ export function getWidgetConfig({
180180}
181181
182182// 解析用户配置的 errorSchema options
183- export function getUserErrOptions ( errorSchema ) {
184- return Object . keys ( errorSchema )
183+ export function getUserErrOptions ( {
184+ schema = { } ,
185+ errorSchema = { }
186+ } ) {
187+ return Object . assign ( { } , ...[ schema , errorSchema ] . map ( itemSchema => Object . keys ( itemSchema )
185188 . filter ( key => key . indexOf ( 'err:' ) === 0 )
186189 . reduce ( ( options , key ) => {
187- const value = errorSchema [ key ] ;
190+ const value = itemSchema [ key ] ;
188191 // options 内外合并
189192 if ( key === 'err:options' && isObject ( value ) ) {
190193 return { ...options , ...value } ;
191194 }
192195 return { ...options , [ key . substring ( 4 ) ] : value } ;
193- } , { } ) ;
196+ } , { } ) ) ) ;
194197}
195198
196199// ui:order object-> properties 排序
Original file line number Diff line number Diff line change @@ -175,7 +175,10 @@ export function validateFormDataAndTransformMsg({
175175 } ;
176176
177177 // 用户设置校验信息
178- const errSchemaMsg = getUserErrOptions ( errorSchema ) . required ;
178+ const errSchemaMsg = getUserErrOptions ( {
179+ schema,
180+ errorSchema
181+ } ) . required ;
179182 if ( errSchemaMsg ) {
180183 requireErrObj . message = errSchemaMsg ;
181184 } else {
@@ -207,7 +210,10 @@ export function validateFormDataAndTransformMsg({
207210 ) ;
208211 }
209212
210- const userErrOptions = getUserErrOptions ( errorSchema ) ;
213+ const userErrOptions = getUserErrOptions ( {
214+ schema,
215+ errorSchema
216+ } ) ;
211217
212218 return ( isOnlyFirstError && ajvErrors . length > 0 ? [ ajvErrors [ 0 ] ] : ajvErrors ) . reduce ( ( preErrors , errorItem ) => {
213219 // 优先获取 errorSchema 配置
Original file line number Diff line number Diff line change @@ -169,7 +169,10 @@ export default {
169169 uiSchema : this . uiSchema
170170 } ) , key => ( key === this . combiningType ? undefined : `ui:${ key } ` ) ) ;
171171
172- const userErrOptions = filterObject ( getUserErrOptions ( this . errorSchema ) , key => ( key === this . combiningType ? undefined : `err:${ key } ` ) ) ;
172+ const userErrOptions = filterObject ( getUserErrOptions ( {
173+ schema : this . schema ,
174+ errorSchema : this . errorSchema
175+ } ) , key => ( key === this . combiningType ? undefined : `err:${ key } ` ) ) ;
173176
174177 childrenVnode . push (
175178 h (
You can’t perform that action at this time.
0 commit comments