@etsoo/appscript 1.2.64 → 1.2.65

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.
@@ -160,6 +160,12 @@ test('Tests for getUnitLabel', () => {
160
160
  expect(app.getUnitLabel(12, true)).toBe('每年');
161
161
  });
162
162
 
163
+ test('Tests for isValidPassword', () => {
164
+ expect(app.isValidPassword('12345678')).toBeFalsy();
165
+ expect(app.isValidPassword('abcd3')).toBeFalsy();
166
+ expect(app.isValidPassword('1234abcd')).toBeTruthy();
167
+ });
168
+
163
169
  test('Tests for getRepeatOptions', () => {
164
170
  const options = BusinessUtils.getRepeatOptions(app.labelDelegate, [
165
171
  'MONTH',
@@ -303,6 +303,11 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
303
303
  * @returns Result
304
304
  */
305
305
  initCall(callback?: (result: boolean) => void, resetKeys?: boolean): Promise<void>;
306
+ /**
307
+ * Is valid password, override to implement custom check
308
+ * @param password Input password
309
+ */
310
+ isValidPassword(password: string): boolean;
306
311
  /**
307
312
  * Callback where exit a page
308
313
  */
@@ -496,6 +501,11 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
496
501
  * Restore settings from persisted source
497
502
  */
498
503
  protected restore(): boolean;
504
+ /**
505
+ * Is valid password, override to implement custom check
506
+ * @param password Input password
507
+ */
508
+ isValidPassword(password: string): boolean;
499
509
  /**
500
510
  * Persist settings to source when application exit
501
511
  */
@@ -195,6 +195,20 @@ class CoreApp {
195
195
  }
196
196
  return false;
197
197
  }
198
+ /**
199
+ * Is valid password, override to implement custom check
200
+ * @param password Input password
201
+ */
202
+ isValidPassword(password) {
203
+ // Length check
204
+ if (password.length < 6)
205
+ return false;
206
+ // One letter and number required
207
+ if (/\d+/gi.test(password) && /[a-z]+/gi.test(password)) {
208
+ return true;
209
+ }
210
+ return false;
211
+ }
198
212
  /**
199
213
  * Persist settings to source when application exit
200
214
  */
@@ -303,6 +303,11 @@ export interface ICoreApp<S extends IAppSettings, N, C extends NotificationCallP
303
303
  * @returns Result
304
304
  */
305
305
  initCall(callback?: (result: boolean) => void, resetKeys?: boolean): Promise<void>;
306
+ /**
307
+ * Is valid password, override to implement custom check
308
+ * @param password Input password
309
+ */
310
+ isValidPassword(password: string): boolean;
306
311
  /**
307
312
  * Callback where exit a page
308
313
  */
@@ -496,6 +501,11 @@ export declare abstract class CoreApp<S extends IAppSettings, N, C extends Notif
496
501
  * Restore settings from persisted source
497
502
  */
498
503
  protected restore(): boolean;
504
+ /**
505
+ * Is valid password, override to implement custom check
506
+ * @param password Input password
507
+ */
508
+ isValidPassword(password: string): boolean;
499
509
  /**
500
510
  * Persist settings to source when application exit
501
511
  */
@@ -192,6 +192,20 @@ export class CoreApp {
192
192
  }
193
193
  return false;
194
194
  }
195
+ /**
196
+ * Is valid password, override to implement custom check
197
+ * @param password Input password
198
+ */
199
+ isValidPassword(password) {
200
+ // Length check
201
+ if (password.length < 6)
202
+ return false;
203
+ // One letter and number required
204
+ if (/\d+/gi.test(password) && /[a-z]+/gi.test(password)) {
205
+ return true;
206
+ }
207
+ return false;
208
+ }
195
209
  /**
196
210
  * Persist settings to source when application exit
197
211
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.2.64",
3
+ "version": "1.2.65",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -420,6 +420,12 @@ export interface ICoreApp<
420
420
  resetKeys?: boolean
421
421
  ): Promise<void>;
422
422
 
423
+ /**
424
+ * Is valid password, override to implement custom check
425
+ * @param password Input password
426
+ */
427
+ isValidPassword(password: string): boolean;
428
+
423
429
  /**
424
430
  * Callback where exit a page
425
431
  */
@@ -795,6 +801,22 @@ export abstract class CoreApp<
795
801
  return false;
796
802
  }
797
803
 
804
+ /**
805
+ * Is valid password, override to implement custom check
806
+ * @param password Input password
807
+ */
808
+ isValidPassword(password: string) {
809
+ // Length check
810
+ if (password.length < 6) return false;
811
+
812
+ // One letter and number required
813
+ if (/\d+/gi.test(password) && /[a-z]+/gi.test(password)) {
814
+ return true;
815
+ }
816
+
817
+ return false;
818
+ }
819
+
798
820
  /**
799
821
  * Persist settings to source when application exit
800
822
  */