@globalbrain/sefirot 3.38.0 → 3.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,7 @@ import { _required } from './validators'
5
5
 
6
6
  export interface RuleOptions {
7
7
  optional?: boolean
8
+ async?: boolean
8
9
  message(params: MessageProps): string
9
10
  validation(value: unknown): boolean | Promise<boolean>
10
11
  }
@@ -18,14 +19,14 @@ export function createRule(
18
19
  ): ValidationRuleWithParams {
19
20
  const lang = useLang()
20
21
 
22
+ function validation(value: unknown) {
23
+ return options.optional && !_required(value)
24
+ ? true
25
+ : options.validation(value)
26
+ }
27
+
21
28
  return helpers.withMessage(
22
- (params) => {
23
- return options.message({ ...params, lang })
24
- },
25
- (value) => {
26
- return options.optional && !_required(value)
27
- ? true
28
- : options.validation(value)
29
- }
29
+ (params) => options.message({ ...params, lang }),
30
+ options.async ? helpers.withAsync(validation) : validation
30
31
  )
31
32
  }
@@ -11,6 +11,7 @@ export function requiredIf(
11
11
  msg?: string
12
12
  ) {
13
13
  return createRule({
14
+ async: true,
14
15
  message: ({ lang }) => msg ?? message[lang],
15
16
  validation: (value) => baseRequiredIf(value, condition)
16
17
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@globalbrain/sefirot",
3
- "version": "3.38.0",
3
+ "version": "3.38.1",
4
4
  "packageManager": "pnpm@8.15.4",
5
5
  "description": "Vue Components for Global Brain Design System.",
6
6
  "author": "Kia Ishii <ka.ishii@globalbrains.com>",