Refactor #439 and docs

pull/457/head
cagataycivici 2020-08-27 13:54:51 +03:00
parent d873d2470d
commit 24c76ee929
4 changed files with 41 additions and 7 deletions

View File

@ -3,8 +3,8 @@ import Vue from 'vue';
export declare class Password extends Vue { export declare class Password extends Vue {
value?: string; value?: string;
promptLabel?: string; promptLabel?: string;
mediumCheckExpr?: string; mediumRegex?: string;
strongCheckExpr?: string; strongRegex?: string;
weakLabel?: string; weakLabel?: string;
mediumLabel?: string; mediumLabel?: string;
strongLabel?: string; strongLabel?: string;

View File

@ -12,11 +12,11 @@ export default {
type: String, type: String,
default: 'Enter a password' default: 'Enter a password'
}, },
mediumCheckExpr: { mediumRegex: {
type: String, type: String,
default: '^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})' // eslint-disable-line default: '^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})' // eslint-disable-line
}, },
strongCheckExpr: { strongRegex: {
type: String, type: String,
default: '^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})' // eslint-disable-line default: '^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})' // eslint-disable-line
}, },
@ -43,8 +43,8 @@ export default {
mediumCheckRegExp: null, mediumCheckRegExp: null,
strongCheckRegExp: null, strongCheckRegExp: null,
mounted() { mounted() {
this.mediumCheckRegExp = new RegExp(this.mediumCheckExpr); this.mediumCheckRegExp = new RegExp(this.mediumRegex);
this.strongCheckRegExp = new RegExp(this.strongCheckExpr); this.strongCheckRegExp = new RegExp(this.strongRegex);
}, },
methods: { methods: {
testStrength(str) { testStrength(str) {

View File

@ -13,6 +13,28 @@ import Password from 'primevue/password';
<Password v-model="value" /> <Password v-model="value" />
</CodeHighlight> </CodeHighlight>
<h5>Customization</h5>
<p>Password components uses regular expressions for middle and strong passwords with the following defaults.</p>
<h6>Medium</h6>
<p><i>^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,}).</i></p>
<ul>
<li>At least one lowercase</li>
<li>At least one uppercase or one number</li>
<li>Minimum 6 characters</li>
</ul>
<h6>Strong</h6>
<p><i>^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})</i></p>
<ul>
<li>At least one lowercase</li>
<li>At least one uppercase</li>
<li>At least one numeric</li>
<li>Minimum 8 characters</li>
</ul>
<p>It is possible to define your own checks with the <i>mediumRegex</i> and <i>strongRegex</i> properties.</p>
<h5>Properties</h5> <h5>Properties</h5>
<p>Any property such as name and placeholder are passed to the underlying input element. Following are the additional properties to configure the component.</p> <p>Any property such as name and placeholder are passed to the underlying input element. Following are the additional properties to configure the component.</p>
<div class="doc-tablewrapper"> <div class="doc-tablewrapper">
@ -32,6 +54,18 @@ import Password from 'primevue/password';
<td>Enter a password</td> <td>Enter a password</td>
<td>Text to prompt password entry.</td> <td>Text to prompt password entry.</td>
</tr> </tr>
<tr>
<td>mediumRegex</td>
<td>string</td>
<td>Regex for a medium level password.</td>
<td>^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,}).</td>
</tr>
<tr>
<td>strongRegex</td>
<td>string</td>
<td>Regex for a strong level password.</td>
<td>^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})</td>
</tr>
<tr> <tr>
<td>weakLabel</td> <td>weakLabel</td>
<td>string</td> <td>string</td>

View File

@ -30,7 +30,7 @@ data() {
<CodeHighlight> <CodeHighlight>
<template v-pre> <template v-pre>
&lt;ProgressBar :value="value"&gt; &lt;ProgressBar :value="value"&gt;
Percent Complete: {{value}}% Percent Complete: &#123;&#123;value&#125;&#125;%
&lt;/ProgressBar&gt; &lt;/ProgressBar&gt;
</template> </template>
</CodeHighlight> </CodeHighlight>