fix(form): lint

This commit is contained in:
07akioni 2021-08-12 00:00:49 +08:00
parent b44901e111
commit 71ec0cb47a
2 changed files with 4 additions and 4 deletions

View File

@ -66,7 +66,7 @@ export default defineComponent({
validateCallback?: FormValidateCallback, validateCallback?: FormValidateCallback,
shouldRuleBeApplied: ApplyRule = () => true shouldRuleBeApplied: ApplyRule = () => true
): Promise<void> { ): Promise<void> {
return new Promise((resolve, reject) => { return await new Promise((resolve, reject) => {
const formItemValidationPromises = [] const formItemValidationPromises = []
for (const key of keysOf(formItems)) { for (const key of keysOf(formItems)) {
const formItemInstances = formItems[key] const formItemInstances = formItems[key]

View File

@ -297,20 +297,20 @@ export default defineComponent({
return shallowClonedRule return shallowClonedRule
}) })
if (!activeRules.length) { if (!activeRules.length) {
return Promise.resolve({ return await Promise.resolve({
valid: true valid: true
}) })
} }
const mergedPath = path ?? '__n_no_path__' const mergedPath = path ?? '__n_no_path__'
const validator = new Schema({ [mergedPath]: activeRules as RuleItem[] }) const validator = new Schema({ [mergedPath]: activeRules as RuleItem[] })
return new Promise((resolve) => { return await new Promise((resolve) => {
void validator.validate( void validator.validate(
{ [mergedPath]: value }, { [mergedPath]: value },
options, options,
(errors, fields) => { (errors, fields) => {
if (errors?.length) { if (errors?.length) {
explainsRef.value = errors.map( explainsRef.value = errors.map(
(error: ValidateError) => error?.message ?? '' (error: ValidateError) => error?.message || ''
) )
validationErroredRef.value = true validationErroredRef.value = true
resolve({ resolve({