fix #3185: validateApi的sendOn属性不生效问题 (#3186)

This commit is contained in:
RUNZE LU 2021-12-10 14:56:58 +08:00 committed by GitHub
parent a79c0b9e70
commit a35c11446e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -0,0 +1,6 @@
{
"status": 422,
"msg": "",
"errors": "当前用户已存在",
"data": null
}

View File

@ -0,0 +1,3 @@
{
"status": 0
}

View File

@ -14,6 +14,7 @@ import {str2rules, validate as doValidate} from '../utils/validations';
import {Api, Payload, fetchOptions} from '../types';
import {ComboStore, IComboStore, IUniqueGroup} from './combo';
import {evalExpression} from '../utils/tpl';
import {isEffectiveApi} from '../utils/api';
import findIndex from 'lodash/findIndex';
import {
isArrayChildrenModified,
@ -320,7 +321,7 @@ export const FormItemStore = StoreNode.named('FormItemStore')
let validateCancel: Function | null = null;
const validate: (data: Object, hook?: any) => Promise<boolean> = flow(
function* validate(data: Object, hook?: any) {
if (self.validating && !self.validateApi) {
if (self.validating && !isEffectiveApi(self.validateApi, data)) {
return self.valid;
}
@ -334,7 +335,7 @@ export const FormItemStore = StoreNode.named('FormItemStore')
doValidate(self.tmpValue, data, self.rules, self.messages, self.__)
);
if (!self.errors.length && self.validateApi) {
if (!self.errors.length && isEffectiveApi(self.validateApi, data)) {
if (validateCancel) {
validateCancel();
validateCancel = null;