Skip to content

Commit

Permalink
fix: update validation command
Browse files Browse the repository at this point in the history
  • Loading branch information
cafadev committed Jul 26, 2024
1 parent 1fb66b3 commit 4204078
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/forms/axioma/commands/validate-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { BaseCommand, BaseHandler } from '@fancy-crud/bus'
import type { BaseObjectWithNormalizedFields, NormalizedField, RuleConfig } from '@packages/core/forms/axioma'
import { meta } from '@fancy-crud/bus'

type MinimumNormalizedField = Pick<NormalizedField, 'rules' | 'errors' | 'modelValue' | 'modelKey'>
type MinimumNormalizedField = Pick<NormalizedField, 'rules' | 'errors' | 'modelValue' | 'modelKey' | 'hidden' | 'exclude'>

export class ValidateFormCommand implements BaseCommand {
public readonly meta = meta(IValidateFormHandler)
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/forms/capabilities/validate-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ export class ValidateFormHandler implements IValidateFormHandler {

execute({ fields, options }: ValidateFormCommand): boolean {
const isValid = Object.values(fields).every((field) => {
const command = new ValidateFieldRulesCommand(field, options)

if (field.hidden || field.exclude)
return true

const command = new ValidateFieldRulesCommand(field, options)
const result = this.validateFieldRules.execute(command)
return result === true
})
Expand Down

0 comments on commit 4204078

Please sign in to comment.