inviton-powerduck 0.0.219 → 0.0.220

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.
@@ -1,7 +1,7 @@
1
- import type { Validation } from '@vuelidate/core';
2
1
  import type { PowerduckViewModelBase } from './base-component';
3
2
  import type { IValidationSet, ValidationRuleset, ValidationState } from './static-wrappers/interfaces/validation-interface';
4
3
  import { Temporal } from '@js-temporal/polyfill';
4
+ import { useVuelidate, type Validation } from '@vuelidate/core';
5
5
  import {
6
6
  alpha,
7
7
  alphaNum,
@@ -22,7 +22,7 @@ import {
22
22
  requiredUnless,
23
23
  url,
24
24
  } from '@vuelidate/validators';
25
- import { unref } from 'vue';
25
+ import { reactive, unref } from 'vue';
26
26
  import PowerduckState from '../app/powerduck-state';
27
27
  import { capitalize } from './extensions/string-extensions';
28
28
  import LocalizedValueHelper from './localized-value-helper';
@@ -134,6 +134,33 @@ export class ValidationHelper {
134
134
  static transformRuleset<T>(ruleSet: ValidationRuleset<T>): any {
135
135
  return ruleSet as any;
136
136
  }
137
+
138
+ static validateModel(ruleSet: ValidationRuleset<any>, item: any): Promise<{
139
+ valid: boolean;
140
+ v$: Validation<any, any>;
141
+ }> {
142
+ const state = reactive(item);
143
+ const v$ = useVuelidate(ruleSet, state).value;
144
+ v$.$touch();
145
+
146
+ return new Promise((resolve) => {
147
+ if (!v$.$pending) {
148
+ resolve({
149
+ valid: !v$.$invalid,
150
+ v$,
151
+ });
152
+
153
+ return;
154
+ }
155
+
156
+ v$.$validate().then((res) => {
157
+ resolve({
158
+ valid: res,
159
+ v$,
160
+ });
161
+ });
162
+ });
163
+ }
137
164
  }
138
165
 
139
166
  const customReq = (value: any): boolean => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "inviton-powerduck",
3
3
  "type": "module",
4
- "version": "0.0.219",
4
+ "version": "0.0.220",
5
5
  "files": [
6
6
  "app/",
7
7
  "common/",