From 24c76ee92905ed59b65f0fee740c3bfdaea9d912 Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Thu, 27 Aug 2020 13:54:51 +0300 Subject: [PATCH] Refactor #439 and docs --- src/components/password/Password.d.ts | 4 +-- src/components/password/Password.vue | 8 +++--- src/views/password/PasswordDoc.vue | 34 ++++++++++++++++++++++++ src/views/progressbar/ProgressBarDoc.vue | 2 +- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/components/password/Password.d.ts b/src/components/password/Password.d.ts index e63b691ed..898e572ba 100755 --- a/src/components/password/Password.d.ts +++ b/src/components/password/Password.d.ts @@ -3,8 +3,8 @@ import Vue from 'vue'; export declare class Password extends Vue { value?: string; promptLabel?: string; - mediumCheckExpr?: string; - strongCheckExpr?: string; + mediumRegex?: string; + strongRegex?: string; weakLabel?: string; mediumLabel?: string; strongLabel?: string; diff --git a/src/components/password/Password.vue b/src/components/password/Password.vue index 893da7caf..dc604bc65 100755 --- a/src/components/password/Password.vue +++ b/src/components/password/Password.vue @@ -12,11 +12,11 @@ export default { type: String, default: 'Enter a password' }, - mediumCheckExpr: { + mediumRegex: { type: String, default: '^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})' // eslint-disable-line }, - strongCheckExpr: { + strongRegex: { type: String, default: '^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})' // eslint-disable-line }, @@ -43,8 +43,8 @@ export default { mediumCheckRegExp: null, strongCheckRegExp: null, mounted() { - this.mediumCheckRegExp = new RegExp(this.mediumCheckExpr); - this.strongCheckRegExp = new RegExp(this.strongCheckExpr); + this.mediumCheckRegExp = new RegExp(this.mediumRegex); + this.strongCheckRegExp = new RegExp(this.strongRegex); }, methods: { testStrength(str) { diff --git a/src/views/password/PasswordDoc.vue b/src/views/password/PasswordDoc.vue index 51f107ead..f3b6e4102 100755 --- a/src/views/password/PasswordDoc.vue +++ b/src/views/password/PasswordDoc.vue @@ -13,6 +13,28 @@ import Password from 'primevue/password'; <Password v-model="value" /> +
Customization
+

Password components uses regular expressions for middle and strong passwords with the following defaults.

+ +
Medium
+

^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,}).

+ + +
Strong
+

^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})

+ + +

It is possible to define your own checks with the mediumRegex and strongRegex properties.

+
Properties

Any property such as name and placeholder are passed to the underlying input element. Following are the additional properties to configure the component.

@@ -32,6 +54,18 @@ import Password from 'primevue/password'; Enter a password Text to prompt password entry. + + mediumRegex + string + Regex for a medium level password. + ^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,}). + + + strongRegex + string + Regex for a strong level password. + ^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,}) + weakLabel string diff --git a/src/views/progressbar/ProgressBarDoc.vue b/src/views/progressbar/ProgressBarDoc.vue index b7f2ae62a..0f12cb3a8 100755 --- a/src/views/progressbar/ProgressBarDoc.vue +++ b/src/views/progressbar/ProgressBarDoc.vue @@ -30,7 +30,7 @@ data() {