Skip to content

Commit a9bcdc4

Browse files
committed
2 parents c018b7e + 18ca95d commit a9bcdc4

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

components/form-model/Form.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const FormProps = {
1717
hideRequiredMark: PropTypes.bool,
1818
model: PropTypes.object,
1919
rules: PropTypes.object,
20+
validateMessages: PropTypes.any,
2021
validateOnRuleChange: PropTypes.bool,
2122
};
2223

components/form-model/FormItem.jsx

+3
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ export default {
142142
}
143143
descriptor[this.prop] = rules;
144144
const validator = new AsyncValidator(descriptor);
145+
if (this.FormContext && this.FormContext.validateMessages) {
146+
validator.messages(this.FormContext.validateMessages);
147+
}
145148
const model = {};
146149
model[this.prop] = this.fieldValue;
147150
validator.validate(model, { firstFields: true }, (errors, invalidFields) => {

types/form-model/form.d.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,14 @@ export declare class FormModel extends AntdComponent {
132132
* validation rules of form
133133
* @type object
134134
*/
135-
136135
rules: object;
136+
137+
/**
138+
* Default validate message. And its format is similar with newMessages's returned value
139+
* @type any
140+
*/
141+
validateMessages?: any;
142+
137143
/**
138144
* whether to trigger validation when the rules prop is changed
139145
* @type Boolean

types/form/form.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ export declare class Form extends AntdComponent {
389389
*/
390390
options: object;
391391

392-
createForm(context: Vue, options?: IformCreateOption): any;
392+
createForm(context: Vue, options?: IformCreateOption): WrappedFormUtils;
393393

394394
/**
395395
* Convert props to field value

0 commit comments

Comments
 (0)