Skip to content

Commit

Permalink
feat: add searchCriteriaNotEmptyValidator (#441)
Browse files Browse the repository at this point in the history
* feat: add searchCriteriaNotEmptyValidator

* fix: rename validator

---------

Co-authored-by: kim.tran <[email protected]>
  • Loading branch information
KimFFVII and kim.tran authored Sep 6, 2024
1 parent 33fda3c commit a2fc73e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions libs/angular-accelerator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export * from './lib/angular-accelerator-primeng.module'

// functions
export * from './lib/functions/flatten-object'
export * from './lib/functions/at-least-one-field-filled-validator'

// utils
export * from './lib/utils/async-translate-loader.utils'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ValidatorFn, AbstractControl, ValidationErrors } from '@angular/forms'

export const atLeastOneFieldFilledValidator: ValidatorFn = (form: AbstractControl): ValidationErrors | null => {
if (Object.values(form.value).every((x) => x === null || x === undefined || x === '')) {
return { allFieldsEmpty: true }
}
return null
}

0 comments on commit a2fc73e

Please sign in to comment.