@beinformed/ui 1.19.0 → 1.19.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.
- package/CHANGELOG.md +6 -0
- package/esm/models/attributes/PasswordAttributeModel.js +4 -5
- package/esm/models/attributes/PasswordAttributeModel.js.map +1 -1
- package/lib/models/attributes/PasswordAttributeModel.js +4 -5
- package/lib/models/attributes/PasswordAttributeModel.js.flow +8 -6
- package/lib/models/attributes/PasswordAttributeModel.js.map +1 -1
- package/package.json +14 -14
- package/src/models/attributes/PasswordAttributeModel.js +8 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.19.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.19.0...v1.19.1) (2022-06-16)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **confirm-password:** confirm constraint only in specific situations ([bf39462](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/bf394622b39c51145411bf4176d055d57488c412))
|
|
10
|
+
|
|
5
11
|
## [1.19.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.18.9...v1.19.0) (2022-06-15)
|
|
6
12
|
|
|
7
13
|
### Features
|
|
@@ -184,7 +184,7 @@ var PasswordAttributeModel = /*#__PURE__*/function (_StringAttributeModel) {
|
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
if (this.layouthint.has(CONFIRM_PASSWORD) && this.
|
|
187
|
+
if (this.layouthint.has(CONFIRM_PASSWORD) && this.isConfirmPassword == null) {
|
|
188
188
|
constraints.add(new PasswordConfirmConstraint(this.confirmValue, this.otherLabel));
|
|
189
189
|
}
|
|
190
190
|
|
|
@@ -198,9 +198,8 @@ var PasswordAttributeModel = /*#__PURE__*/function (_StringAttributeModel) {
|
|
|
198
198
|
key: "constraintCollection",
|
|
199
199
|
get: function get() {
|
|
200
200
|
if (this.isConfirmPassword) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
return constraints;
|
|
201
|
+
// confirm password only needs local constraints, no server constraints
|
|
202
|
+
return this.getConfirmPasswordConstraints();
|
|
204
203
|
}
|
|
205
204
|
|
|
206
205
|
return _get(_getPrototypeOf(PasswordAttributeModel.prototype), "constraintCollection", this);
|
|
@@ -211,7 +210,7 @@ var PasswordAttributeModel = /*#__PURE__*/function (_StringAttributeModel) {
|
|
|
211
210
|
}, {
|
|
212
211
|
key: "isConfirmPassword",
|
|
213
212
|
get: function get() {
|
|
214
|
-
return this._isConfirmPassword
|
|
213
|
+
return this._isConfirmPassword;
|
|
215
214
|
}
|
|
216
215
|
/**
|
|
217
216
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordAttributeModel.js","names":["StringAttributeModel","ConstraintCollection","PasswordLowerAndUpperCaseConstraint","PasswordThreeConsecutiveCharactersNotAllowedConstraint","PasswordMinNumericCharactersConstraint","PasswordMinSpecialCharactersConstraint","RegexConstraint","PasswordConfirmConstraint","CONFIRM_PASSWORD","PasswordAttributeModel","value","updateLastModification","inputvalue","getContribution","constraints","upperAndLowerCaseMandatory","maxSequenceOfIdenticalCharacters","maxSequenceOfUsernameCharacters","minNumberOfNumericCharacters","minNumberOfSpecialCharacters","regexConstraint","isConfirmPassword","getConfirmPasswordConstraints","getStandardPasswordConstraints","add","confirmValue","otherLabel","regexConstraints","length","forEach","layouthint","has","addConstraints","_isConfirmPassword","_confirmValue","validate","_otherLabel","useClientsideValidation","isOptionalAndEmpty","_isValid","_validatedValue","constraintCollection","inError","name","contributions","type","Array","isArray"],"sources":["../../../src/models/attributes/PasswordAttributeModel.js"],"sourcesContent":["// @flow\nimport StringAttributeModel from \"./StringAttributeModel\";\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\n\nimport PasswordLowerAndUpperCaseConstraint from \"./input-constraints/PasswordLowerAndUpperCaseConstraint\";\nimport PasswordThreeConsecutiveCharactersNotAllowedConstraint from \"./input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint\";\nimport PasswordMinNumericCharactersConstraint from \"./input-constraints/PasswordMinNumericCharactersConstraint\";\nimport PasswordMinSpecialCharactersConstraint from \"./input-constraints/PasswordMinSpecialCharactersConstraint\";\nimport RegexConstraint from \"./input-constraints/RegexConstraint\";\nimport PasswordConfirmConstraint from \"./input-constraints/PasswordConfirmConstraint\";\n\nimport { CONFIRM_PASSWORD } from \"../../constants/LayoutHints\";\n\nimport type { RegexObject } from \"./input-constraints/RegexConstraint\";\n\n/**\n * Password attribute\n */\nexport default class PasswordAttributeModel extends StringAttributeModel {\n _confirmValue: string;\n _isConfirmPassword: boolean;\n _otherLabel: string;\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n const layouthint = contributions?.layouthint;\n return (\n contributions.type === \"password\" ||\n (Array.isArray(layouthint) && layouthint.includes(\"password\"))\n );\n }\n\n /**\n */\n get type(): string {\n return \"password\";\n }\n\n /**\n * Update the attribute by name and value\n */\n update(value: string): PasswordAttributeModel {\n this.updateLastModification();\n this.inputvalue = value;\n\n return this;\n }\n\n /**\n */\n get constraints(): Object {\n return this.getContribution(\"constraints\", {});\n }\n\n /**\n */\n get upperAndLowerCaseMandatory(): ?boolean {\n return this.constraints.upperAndLowerCaseMandatory;\n }\n\n /**\n */\n get maxSequenceOfIdenticalCharacters(): ?number {\n return this.constraints.maxSequenceOfIdenticalCharacters;\n }\n\n /**\n */\n get maxSequenceOfUsernameCharacters(): ?number {\n return this.constraints.maxSequenceOfUsernameCharacters;\n }\n\n /**\n */\n get minNumberOfNumericCharacters(): ?number {\n return this.constraints.minNumberOfNumericCharacters;\n }\n\n /**\n */\n get minNumberOfSpecialCharacters(): ?number {\n return this.constraints.minNumberOfSpecialCharacters;\n }\n\n /**\n */\n get regexConstraints(): ?Array<RegexObject> {\n return this.constraints.regexConstraint;\n }\n\n /**\n * Add password constraints\n */\n addConstraints(): ConstraintCollection {\n if (this.isConfirmPassword) {\n return this.getConfirmPasswordConstraints();\n }\n return this.getStandardPasswordConstraints();\n }\n\n /**\n * Constraints for a confirmation password\n */\n getConfirmPasswordConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n constraints.add(\n new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)\n );\n return constraints;\n }\n\n /**\n * Constrains for a standard password\n */\n getStandardPasswordConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n if (this.upperAndLowerCaseMandatory) {\n constraints.add(new PasswordLowerAndUpperCaseConstraint());\n }\n\n if (this.maxSequenceOfIdenticalCharacters) {\n constraints.add(\n new PasswordThreeConsecutiveCharactersNotAllowedConstraint(\n this.maxSequenceOfIdenticalCharacters\n )\n );\n }\n\n if (this.minNumberOfNumericCharacters) {\n constraints.add(\n new PasswordMinNumericCharactersConstraint(\n this.minNumberOfNumericCharacters\n )\n );\n }\n\n if (this.minNumberOfSpecialCharacters) {\n constraints.add(\n new PasswordMinSpecialCharactersConstraint(\n this.minNumberOfSpecialCharacters\n )\n );\n }\n\n if (this.regexConstraints && this.regexConstraints.length > 0) {\n this.regexConstraints.forEach((regexConstraint) => {\n constraints.add(new RegexConstraint(regexConstraint));\n });\n }\n\n if (this.layouthint.has(CONFIRM_PASSWORD) && this.confirmValue !== \"\") {\n constraints.add(\n new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)\n );\n }\n\n return constraints;\n }\n\n /**\n * Retrieve applicable constraint for this attribute\n */\n get constraintCollection(): ConstraintCollection {\n if (this.isConfirmPassword) {\n const constraints = new ConstraintCollection();\n constraints.add(this.addConstraints());\n return constraints;\n }\n\n return super.constraintCollection;\n }\n\n /**\n */\n get isConfirmPassword(): boolean {\n return this._isConfirmPassword || false;\n }\n\n /**\n */\n set isConfirmPassword(isConfirmPassword: boolean) {\n this._isConfirmPassword = isConfirmPassword;\n }\n\n /**\n */\n get confirmValue(): string {\n return this._confirmValue || \"\";\n }\n\n /**\n */\n set confirmValue(confirmValue: string) {\n this._confirmValue = confirmValue;\n\n this.validate(this.inputvalue);\n }\n\n /**\n */\n get otherLabel(): string {\n return this._otherLabel;\n }\n\n /**\n */\n set otherLabel(otherLabel: string) {\n this._otherLabel = otherLabel;\n }\n\n /**\n * Validate input\n */\n validate(value: string): boolean {\n // when client side validation is disabled, this attribute is always valid\n if (!this.useClientsideValidation()) {\n return true;\n }\n\n if (this.isOptionalAndEmpty(value)) {\n this._isValid = true;\n } else if (this._validatedValue !== `${this.confirmValue}-${value}`) {\n this._isValid = this.constraintCollection.validate(value);\n }\n this._validatedValue = `${this.confirmValue}-${value}`;\n\n return this._isValid;\n }\n\n /**\n */\n getFormData(): { [string]: any } | null {\n if (this.isConfirmPassword || this.inError()) {\n return null;\n }\n\n return {\n [this.name]: this.value,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA,OAAOA,oBAAP,MAAiC,wBAAjC;AACA,OAAOC,oBAAP,MAAiC,0CAAjC;AAEA,OAAOC,mCAAP,MAAgD,yDAAhD;AACA,OAAOC,sDAAP,MAAmE,4EAAnE;AACA,OAAOC,sCAAP,MAAmD,4DAAnD;AACA,OAAOC,sCAAP,MAAmD,4DAAnD;AACA,OAAOC,eAAP,MAA4B,qCAA5B;AACA,OAAOC,yBAAP,MAAsC,+CAAtC;AAEA,SAASC,gBAAT,QAAiC,6BAAjC;;AAIA;AACA;AACA;IACqBC,sB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAenB;AACF;IACE,eAAmB;MACjB,OAAO,UAAP;IACD;IAED;AACF;AACA;;;;WACE,gBAAOC,KAAP,EAA8C;MAC5C,KAAKC,sBAAL;MACA,KAAKC,UAAL,GAAkBF,KAAlB;MAEA,OAAO,IAAP;IACD;IAED;AACF;;;;SACE,eAA0B;MACxB,OAAO,KAAKG,eAAL,CAAqB,aAArB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;AACF;AACA;;;;WACE,kBAAShB,KAAT,EAAiC;MAAA;;MAC/B;MACA,IAAI,CAAC,KAAK2B,uBAAL,EAAL,EAAqC;QACnC,OAAO,IAAP;MACD;;MAED,IAAI,KAAKC,kBAAL,CAAwB5B,KAAxB,CAAJ,EAAoC;QAClC,KAAK6B,QAAL,GAAgB,IAAhB;MACD,CAFD,MAEO,IAAI,KAAKC,eAAL,mDAA4B,KAAKf,YAAjC,wBAAiDf,KAAjD,CAAJ,EAA8D;QACnE,KAAK6B,QAAL,GAAgB,KAAKE,oBAAL,CAA0BN,QAA1B,CAAmCzB,KAAnC,CAAhB;MACD;;MACD,KAAK8B,eAAL,iDAA0B,KAAKf,YAA/B,wBAA+Cf,KAA/C;MAEA,OAAO,KAAK6B,QAAZ;IACD;IAED;AACF;;;;WACE,uBAAwC;MACtC,IAAI,KAAKlB,iBAAL,IAA0B,KAAKqB,OAAL,EAA9B,EAA8C;QAC5C,OAAO,IAAP;MACD;;MAED,2BACG,KAAKC,IADR,EACe,KAAKjC,KADpB;IAGD;;;;IA1ND;AACF;IACE,2BAAyBkC,aAAzB,EAAyD;MACvD,IAAMd,UAAU,GAAGc,aAAH,aAAGA,aAAH,uBAAGA,aAAa,CAAEd,UAAlC;MACA,OACEc,aAAa,CAACC,IAAd,KAAuB,UAAvB,IACCC,KAAK,CAACC,OAAN,CAAcjB,UAAd,KAA6B,0BAAAA,UAAU,MAAV,CAAAA,UAAU,EAAU,UAAV,CAF1C;IAID;;;;EAbiD9B,oB;;SAA/BS,sB"}
|
|
1
|
+
{"version":3,"file":"PasswordAttributeModel.js","names":["StringAttributeModel","ConstraintCollection","PasswordLowerAndUpperCaseConstraint","PasswordThreeConsecutiveCharactersNotAllowedConstraint","PasswordMinNumericCharactersConstraint","PasswordMinSpecialCharactersConstraint","RegexConstraint","PasswordConfirmConstraint","CONFIRM_PASSWORD","PasswordAttributeModel","value","updateLastModification","inputvalue","getContribution","constraints","upperAndLowerCaseMandatory","maxSequenceOfIdenticalCharacters","maxSequenceOfUsernameCharacters","minNumberOfNumericCharacters","minNumberOfSpecialCharacters","regexConstraint","isConfirmPassword","getConfirmPasswordConstraints","getStandardPasswordConstraints","add","confirmValue","otherLabel","regexConstraints","length","forEach","layouthint","has","_isConfirmPassword","_confirmValue","validate","_otherLabel","useClientsideValidation","isOptionalAndEmpty","_isValid","_validatedValue","constraintCollection","inError","name","contributions","type","Array","isArray"],"sources":["../../../src/models/attributes/PasswordAttributeModel.js"],"sourcesContent":["// @flow\nimport StringAttributeModel from \"./StringAttributeModel\";\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\n\nimport PasswordLowerAndUpperCaseConstraint from \"./input-constraints/PasswordLowerAndUpperCaseConstraint\";\nimport PasswordThreeConsecutiveCharactersNotAllowedConstraint from \"./input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint\";\nimport PasswordMinNumericCharactersConstraint from \"./input-constraints/PasswordMinNumericCharactersConstraint\";\nimport PasswordMinSpecialCharactersConstraint from \"./input-constraints/PasswordMinSpecialCharactersConstraint\";\nimport RegexConstraint from \"./input-constraints/RegexConstraint\";\nimport PasswordConfirmConstraint from \"./input-constraints/PasswordConfirmConstraint\";\n\nimport { CONFIRM_PASSWORD } from \"../../constants/LayoutHints\";\n\nimport type { RegexObject } from \"./input-constraints/RegexConstraint\";\n\n/**\n * Password attribute\n */\nexport default class PasswordAttributeModel extends StringAttributeModel {\n _confirmValue: string;\n _isConfirmPassword: boolean;\n _otherLabel: string;\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n const layouthint = contributions?.layouthint;\n return (\n contributions.type === \"password\" ||\n (Array.isArray(layouthint) && layouthint.includes(\"password\"))\n );\n }\n\n /**\n */\n get type(): string {\n return \"password\";\n }\n\n /**\n * Update the attribute by name and value\n */\n update(value: string): PasswordAttributeModel {\n this.updateLastModification();\n this.inputvalue = value;\n\n return this;\n }\n\n /**\n */\n get constraints(): Object {\n return this.getContribution(\"constraints\", {});\n }\n\n /**\n */\n get upperAndLowerCaseMandatory(): ?boolean {\n return this.constraints.upperAndLowerCaseMandatory;\n }\n\n /**\n */\n get maxSequenceOfIdenticalCharacters(): ?number {\n return this.constraints.maxSequenceOfIdenticalCharacters;\n }\n\n /**\n */\n get maxSequenceOfUsernameCharacters(): ?number {\n return this.constraints.maxSequenceOfUsernameCharacters;\n }\n\n /**\n */\n get minNumberOfNumericCharacters(): ?number {\n return this.constraints.minNumberOfNumericCharacters;\n }\n\n /**\n */\n get minNumberOfSpecialCharacters(): ?number {\n return this.constraints.minNumberOfSpecialCharacters;\n }\n\n /**\n */\n get regexConstraints(): ?Array<RegexObject> {\n return this.constraints.regexConstraint;\n }\n\n /**\n * Add password constraints\n */\n addConstraints(): ConstraintCollection {\n if (this.isConfirmPassword) {\n return this.getConfirmPasswordConstraints();\n }\n return this.getStandardPasswordConstraints();\n }\n\n /**\n * Constraints for a confirmation password\n */\n getConfirmPasswordConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n constraints.add(\n new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)\n );\n return constraints;\n }\n\n /**\n * Constrains for a standard password\n */\n getStandardPasswordConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n if (this.upperAndLowerCaseMandatory) {\n constraints.add(new PasswordLowerAndUpperCaseConstraint());\n }\n\n if (this.maxSequenceOfIdenticalCharacters) {\n constraints.add(\n new PasswordThreeConsecutiveCharactersNotAllowedConstraint(\n this.maxSequenceOfIdenticalCharacters\n )\n );\n }\n\n if (this.minNumberOfNumericCharacters) {\n constraints.add(\n new PasswordMinNumericCharactersConstraint(\n this.minNumberOfNumericCharacters\n )\n );\n }\n\n if (this.minNumberOfSpecialCharacters) {\n constraints.add(\n new PasswordMinSpecialCharactersConstraint(\n this.minNumberOfSpecialCharacters\n )\n );\n }\n\n if (this.regexConstraints && this.regexConstraints.length > 0) {\n this.regexConstraints.forEach((regexConstraint) => {\n constraints.add(new RegexConstraint(regexConstraint));\n });\n }\n\n if (\n this.layouthint.has(CONFIRM_PASSWORD) &&\n this.isConfirmPassword == null\n ) {\n constraints.add(\n new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)\n );\n }\n\n return constraints;\n }\n\n /**\n * Retrieve applicable constraint for this attribute\n */\n get constraintCollection(): ConstraintCollection {\n if (this.isConfirmPassword) {\n // confirm password only needs local constraints, no server constraints\n return this.getConfirmPasswordConstraints();\n }\n\n return super.constraintCollection;\n }\n\n /**\n */\n get isConfirmPassword(): boolean | null {\n return this._isConfirmPassword;\n }\n\n /**\n */\n set isConfirmPassword(isConfirmPassword: boolean) {\n this._isConfirmPassword = isConfirmPassword;\n }\n\n /**\n */\n get confirmValue(): string {\n return this._confirmValue || \"\";\n }\n\n /**\n */\n set confirmValue(confirmValue: string) {\n this._confirmValue = confirmValue;\n\n this.validate(this.inputvalue);\n }\n\n /**\n */\n get otherLabel(): string {\n return this._otherLabel;\n }\n\n /**\n */\n set otherLabel(otherLabel: string) {\n this._otherLabel = otherLabel;\n }\n\n /**\n * Validate input\n */\n validate(value: string): boolean {\n // when client side validation is disabled, this attribute is always valid\n if (!this.useClientsideValidation()) {\n return true;\n }\n\n if (this.isOptionalAndEmpty(value)) {\n this._isValid = true;\n } else if (this._validatedValue !== `${this.confirmValue}-${value}`) {\n this._isValid = this.constraintCollection.validate(value);\n }\n this._validatedValue = `${this.confirmValue}-${value}`;\n\n return this._isValid;\n }\n\n /**\n */\n getFormData(): { [string]: any } | null {\n if (this.isConfirmPassword || this.inError()) {\n return null;\n }\n\n return {\n [this.name]: this.value,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA,OAAOA,oBAAP,MAAiC,wBAAjC;AACA,OAAOC,oBAAP,MAAiC,0CAAjC;AAEA,OAAOC,mCAAP,MAAgD,yDAAhD;AACA,OAAOC,sDAAP,MAAmE,4EAAnE;AACA,OAAOC,sCAAP,MAAmD,4DAAnD;AACA,OAAOC,sCAAP,MAAmD,4DAAnD;AACA,OAAOC,eAAP,M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,7 +207,7 @@ var PasswordAttributeModel = /*#__PURE__*/function (_StringAttributeModel) {
|
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
if (this.layouthint.has(_LayoutHints.CONFIRM_PASSWORD) && this.
|
|
210
|
+
if (this.layouthint.has(_LayoutHints.CONFIRM_PASSWORD) && this.isConfirmPassword == null) {
|
|
211
211
|
constraints.add(new _PasswordConfirmConstraint.default(this.confirmValue, this.otherLabel));
|
|
212
212
|
}
|
|
213
213
|
|
|
@@ -221,9 +221,8 @@ var PasswordAttributeModel = /*#__PURE__*/function (_StringAttributeModel) {
|
|
|
221
221
|
key: "constraintCollection",
|
|
222
222
|
get: function get() {
|
|
223
223
|
if (this.isConfirmPassword) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return constraints;
|
|
224
|
+
// confirm password only needs local constraints, no server constraints
|
|
225
|
+
return this.getConfirmPasswordConstraints();
|
|
227
226
|
}
|
|
228
227
|
|
|
229
228
|
return (0, _get2.default)((0, _getPrototypeOf2.default)(PasswordAttributeModel.prototype), "constraintCollection", this);
|
|
@@ -234,7 +233,7 @@ var PasswordAttributeModel = /*#__PURE__*/function (_StringAttributeModel) {
|
|
|
234
233
|
}, {
|
|
235
234
|
key: "isConfirmPassword",
|
|
236
235
|
get: function get() {
|
|
237
|
-
return this._isConfirmPassword
|
|
236
|
+
return this._isConfirmPassword;
|
|
238
237
|
}
|
|
239
238
|
/**
|
|
240
239
|
*/
|
|
@@ -150,7 +150,10 @@ export default class PasswordAttributeModel extends StringAttributeModel {
|
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
if (
|
|
153
|
+
if (
|
|
154
|
+
this.layouthint.has(CONFIRM_PASSWORD) &&
|
|
155
|
+
this.isConfirmPassword == null
|
|
156
|
+
) {
|
|
154
157
|
constraints.add(
|
|
155
158
|
new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)
|
|
156
159
|
);
|
|
@@ -164,9 +167,8 @@ export default class PasswordAttributeModel extends StringAttributeModel {
|
|
|
164
167
|
*/
|
|
165
168
|
get constraintCollection(): ConstraintCollection {
|
|
166
169
|
if (this.isConfirmPassword) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return constraints;
|
|
170
|
+
// confirm password only needs local constraints, no server constraints
|
|
171
|
+
return this.getConfirmPasswordConstraints();
|
|
170
172
|
}
|
|
171
173
|
|
|
172
174
|
return super.constraintCollection;
|
|
@@ -174,8 +176,8 @@ export default class PasswordAttributeModel extends StringAttributeModel {
|
|
|
174
176
|
|
|
175
177
|
/**
|
|
176
178
|
*/
|
|
177
|
-
get isConfirmPassword(): boolean {
|
|
178
|
-
return this._isConfirmPassword
|
|
179
|
+
get isConfirmPassword(): boolean | null {
|
|
180
|
+
return this._isConfirmPassword;
|
|
179
181
|
}
|
|
180
182
|
|
|
181
183
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordAttributeModel.js","names":["PasswordAttributeModel","value","updateLastModification","inputvalue","getContribution","constraints","upperAndLowerCaseMandatory","maxSequenceOfIdenticalCharacters","maxSequenceOfUsernameCharacters","minNumberOfNumericCharacters","minNumberOfSpecialCharacters","regexConstraint","isConfirmPassword","getConfirmPasswordConstraints","getStandardPasswordConstraints","ConstraintCollection","add","PasswordConfirmConstraint","confirmValue","otherLabel","PasswordLowerAndUpperCaseConstraint","PasswordThreeConsecutiveCharactersNotAllowedConstraint","PasswordMinNumericCharactersConstraint","PasswordMinSpecialCharactersConstraint","regexConstraints","length","forEach","RegexConstraint","layouthint","has","CONFIRM_PASSWORD","addConstraints","_isConfirmPassword","_confirmValue","validate","_otherLabel","useClientsideValidation","isOptionalAndEmpty","_isValid","_validatedValue","constraintCollection","inError","name","contributions","type","Array","isArray","StringAttributeModel"],"sources":["../../../src/models/attributes/PasswordAttributeModel.js"],"sourcesContent":["// @flow\nimport StringAttributeModel from \"./StringAttributeModel\";\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\n\nimport PasswordLowerAndUpperCaseConstraint from \"./input-constraints/PasswordLowerAndUpperCaseConstraint\";\nimport PasswordThreeConsecutiveCharactersNotAllowedConstraint from \"./input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint\";\nimport PasswordMinNumericCharactersConstraint from \"./input-constraints/PasswordMinNumericCharactersConstraint\";\nimport PasswordMinSpecialCharactersConstraint from \"./input-constraints/PasswordMinSpecialCharactersConstraint\";\nimport RegexConstraint from \"./input-constraints/RegexConstraint\";\nimport PasswordConfirmConstraint from \"./input-constraints/PasswordConfirmConstraint\";\n\nimport { CONFIRM_PASSWORD } from \"../../constants/LayoutHints\";\n\nimport type { RegexObject } from \"./input-constraints/RegexConstraint\";\n\n/**\n * Password attribute\n */\nexport default class PasswordAttributeModel extends StringAttributeModel {\n _confirmValue: string;\n _isConfirmPassword: boolean;\n _otherLabel: string;\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n const layouthint = contributions?.layouthint;\n return (\n contributions.type === \"password\" ||\n (Array.isArray(layouthint) && layouthint.includes(\"password\"))\n );\n }\n\n /**\n */\n get type(): string {\n return \"password\";\n }\n\n /**\n * Update the attribute by name and value\n */\n update(value: string): PasswordAttributeModel {\n this.updateLastModification();\n this.inputvalue = value;\n\n return this;\n }\n\n /**\n */\n get constraints(): Object {\n return this.getContribution(\"constraints\", {});\n }\n\n /**\n */\n get upperAndLowerCaseMandatory(): ?boolean {\n return this.constraints.upperAndLowerCaseMandatory;\n }\n\n /**\n */\n get maxSequenceOfIdenticalCharacters(): ?number {\n return this.constraints.maxSequenceOfIdenticalCharacters;\n }\n\n /**\n */\n get maxSequenceOfUsernameCharacters(): ?number {\n return this.constraints.maxSequenceOfUsernameCharacters;\n }\n\n /**\n */\n get minNumberOfNumericCharacters(): ?number {\n return this.constraints.minNumberOfNumericCharacters;\n }\n\n /**\n */\n get minNumberOfSpecialCharacters(): ?number {\n return this.constraints.minNumberOfSpecialCharacters;\n }\n\n /**\n */\n get regexConstraints(): ?Array<RegexObject> {\n return this.constraints.regexConstraint;\n }\n\n /**\n * Add password constraints\n */\n addConstraints(): ConstraintCollection {\n if (this.isConfirmPassword) {\n return this.getConfirmPasswordConstraints();\n }\n return this.getStandardPasswordConstraints();\n }\n\n /**\n * Constraints for a confirmation password\n */\n getConfirmPasswordConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n constraints.add(\n new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)\n );\n return constraints;\n }\n\n /**\n * Constrains for a standard password\n */\n getStandardPasswordConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n if (this.upperAndLowerCaseMandatory) {\n constraints.add(new PasswordLowerAndUpperCaseConstraint());\n }\n\n if (this.maxSequenceOfIdenticalCharacters) {\n constraints.add(\n new PasswordThreeConsecutiveCharactersNotAllowedConstraint(\n this.maxSequenceOfIdenticalCharacters\n )\n );\n }\n\n if (this.minNumberOfNumericCharacters) {\n constraints.add(\n new PasswordMinNumericCharactersConstraint(\n this.minNumberOfNumericCharacters\n )\n );\n }\n\n if (this.minNumberOfSpecialCharacters) {\n constraints.add(\n new PasswordMinSpecialCharactersConstraint(\n this.minNumberOfSpecialCharacters\n )\n );\n }\n\n if (this.regexConstraints && this.regexConstraints.length > 0) {\n this.regexConstraints.forEach((regexConstraint) => {\n constraints.add(new RegexConstraint(regexConstraint));\n });\n }\n\n if (this.layouthint.has(CONFIRM_PASSWORD) && this.confirmValue !== \"\") {\n constraints.add(\n new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)\n );\n }\n\n return constraints;\n }\n\n /**\n * Retrieve applicable constraint for this attribute\n */\n get constraintCollection(): ConstraintCollection {\n if (this.isConfirmPassword) {\n const constraints = new ConstraintCollection();\n constraints.add(this.addConstraints());\n return constraints;\n }\n\n return super.constraintCollection;\n }\n\n /**\n */\n get isConfirmPassword(): boolean {\n return this._isConfirmPassword || false;\n }\n\n /**\n */\n set isConfirmPassword(isConfirmPassword: boolean) {\n this._isConfirmPassword = isConfirmPassword;\n }\n\n /**\n */\n get confirmValue(): string {\n return this._confirmValue || \"\";\n }\n\n /**\n */\n set confirmValue(confirmValue: string) {\n this._confirmValue = confirmValue;\n\n this.validate(this.inputvalue);\n }\n\n /**\n */\n get otherLabel(): string {\n return this._otherLabel;\n }\n\n /**\n */\n set otherLabel(otherLabel: string) {\n this._otherLabel = otherLabel;\n }\n\n /**\n * Validate input\n */\n validate(value: string): boolean {\n // when client side validation is disabled, this attribute is always valid\n if (!this.useClientsideValidation()) {\n return true;\n }\n\n if (this.isOptionalAndEmpty(value)) {\n this._isValid = true;\n } else if (this._validatedValue !== `${this.confirmValue}-${value}`) {\n this._isValid = this.constraintCollection.validate(value);\n }\n this._validatedValue = `${this.confirmValue}-${value}`;\n\n return this._isValid;\n }\n\n /**\n */\n getFormData(): { [string]: any } | null {\n if (this.isConfirmPassword || this.inError()) {\n return null;\n }\n\n return {\n [this.name]: this.value,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAIA;AACA;AACA;IACqBA,sB;;;;;;;;;;;;;;;;;;;;;;;;;;IAenB;AACF;IACE,eAAmB;MACjB,OAAO,UAAP;IACD;IAED;AACF;AACA;;;;WACE,gBAAOC,KAAP,EAA8C;MAC5C,KAAKC,sBAAL;MACA,KAAKC,UAAL,GAAkBF,KAAlB;MAEA,OAAO,IAAP;IACD;IAED;AACF;;;;SACE,eAA0B;MACxB,OAAO,KAAKG,eAAL,CAAqB,aAArB,EAAoC,EAApC,CAAP;IACD;IAED;AACF;;;;SACE,eAA2C;MACzC,OAAO,KAAKC,WAAL,CAAiBC,0BAAxB;IACD;IAED;AACF;;;;SACE,eAAgD;MAC9C,OAAO,KAAKD,WAAL,CAAiBE,gCAAxB;IACD;IAED;AACF;;;;SACE,eAA+C;MAC7C,OAAO,KAAKF,WAAL,CAAiBG,+BAAxB;IACD;IAED;AACF;;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KAAKrB,YAAjC,wBAAiDjB,KAAjD,CAAJ,EAA8D;QACnE,KAAKqC,QAAL,GAAgB,KAAKE,oBAAL,CAA0BN,QAA1B,CAAmCjC,KAAnC,CAAhB;MACD;;MACD,KAAKsC,eAAL,8CAA0B,KAAKrB,YAA/B,wBAA+CjB,KAA/C;MAEA,OAAO,KAAKqC,QAAZ;IACD;IAED;AACF;;;;WACE,uBAAwC;MACtC,IAAI,KAAK1B,iBAAL,IAA0B,KAAK6B,OAAL,EAA9B,EAA8C;QAC5C,OAAO,IAAP;MACD;;MAED,yCACG,KAAKC,IADR,EACe,KAAKzC,KADpB;IAGD;;;;IA1ND;AACF;IACE,2BAAyB0C,aAAzB,EAAyD;MACvD,IAAMf,UAAU,GAAGe,aAAH,aAAGA,aAAH,uBAAGA,aAAa,CAAEf,UAAlC;MACA,OACEe,aAAa,CAACC,IAAd,KAAuB,UAAvB,IACCC,KAAK,CAACC,OAAN,CAAclB,UAAd,KAA6B,uBAAAA,UAAU,MAAV,CAAAA,UAAU,EAAU,UAAV,CAF1C;IAID;;;EAbiDmB,8B"}
|
|
1
|
+
{"version":3,"file":"PasswordAttributeModel.js","names":["PasswordAttributeModel","value","updateLastModification","inputvalue","getContribution","constraints","upperAndLowerCaseMandatory","maxSequenceOfIdenticalCharacters","maxSequenceOfUsernameCharacters","minNumberOfNumericCharacters","minNumberOfSpecialCharacters","regexConstraint","isConfirmPassword","getConfirmPasswordConstraints","getStandardPasswordConstraints","ConstraintCollection","add","PasswordConfirmConstraint","confirmValue","otherLabel","PasswordLowerAndUpperCaseConstraint","PasswordThreeConsecutiveCharactersNotAllowedConstraint","PasswordMinNumericCharactersConstraint","PasswordMinSpecialCharactersConstraint","regexConstraints","length","forEach","RegexConstraint","layouthint","has","CONFIRM_PASSWORD","_isConfirmPassword","_confirmValue","validate","_otherLabel","useClientsideValidation","isOptionalAndEmpty","_isValid","_validatedValue","constraintCollection","inError","name","contributions","type","Array","isArray","StringAttributeModel"],"sources":["../../../src/models/attributes/PasswordAttributeModel.js"],"sourcesContent":["// @flow\nimport StringAttributeModel from \"./StringAttributeModel\";\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\n\nimport PasswordLowerAndUpperCaseConstraint from \"./input-constraints/PasswordLowerAndUpperCaseConstraint\";\nimport PasswordThreeConsecutiveCharactersNotAllowedConstraint from \"./input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint\";\nimport PasswordMinNumericCharactersConstraint from \"./input-constraints/PasswordMinNumericCharactersConstraint\";\nimport PasswordMinSpecialCharactersConstraint from \"./input-constraints/PasswordMinSpecialCharactersConstraint\";\nimport RegexConstraint from \"./input-constraints/RegexConstraint\";\nimport PasswordConfirmConstraint from \"./input-constraints/PasswordConfirmConstraint\";\n\nimport { CONFIRM_PASSWORD } from \"../../constants/LayoutHints\";\n\nimport type { RegexObject } from \"./input-constraints/RegexConstraint\";\n\n/**\n * Password attribute\n */\nexport default class PasswordAttributeModel extends StringAttributeModel {\n _confirmValue: string;\n _isConfirmPassword: boolean;\n _otherLabel: string;\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n const layouthint = contributions?.layouthint;\n return (\n contributions.type === \"password\" ||\n (Array.isArray(layouthint) && layouthint.includes(\"password\"))\n );\n }\n\n /**\n */\n get type(): string {\n return \"password\";\n }\n\n /**\n * Update the attribute by name and value\n */\n update(value: string): PasswordAttributeModel {\n this.updateLastModification();\n this.inputvalue = value;\n\n return this;\n }\n\n /**\n */\n get constraints(): Object {\n return this.getContribution(\"constraints\", {});\n }\n\n /**\n */\n get upperAndLowerCaseMandatory(): ?boolean {\n return this.constraints.upperAndLowerCaseMandatory;\n }\n\n /**\n */\n get maxSequenceOfIdenticalCharacters(): ?number {\n return this.constraints.maxSequenceOfIdenticalCharacters;\n }\n\n /**\n */\n get maxSequenceOfUsernameCharacters(): ?number {\n return this.constraints.maxSequenceOfUsernameCharacters;\n }\n\n /**\n */\n get minNumberOfNumericCharacters(): ?number {\n return this.constraints.minNumberOfNumericCharacters;\n }\n\n /**\n */\n get minNumberOfSpecialCharacters(): ?number {\n return this.constraints.minNumberOfSpecialCharacters;\n }\n\n /**\n */\n get regexConstraints(): ?Array<RegexObject> {\n return this.constraints.regexConstraint;\n }\n\n /**\n * Add password constraints\n */\n addConstraints(): ConstraintCollection {\n if (this.isConfirmPassword) {\n return this.getConfirmPasswordConstraints();\n }\n return this.getStandardPasswordConstraints();\n }\n\n /**\n * Constraints for a confirmation password\n */\n getConfirmPasswordConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n constraints.add(\n new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)\n );\n return constraints;\n }\n\n /**\n * Constrains for a standard password\n */\n getStandardPasswordConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n if (this.upperAndLowerCaseMandatory) {\n constraints.add(new PasswordLowerAndUpperCaseConstraint());\n }\n\n if (this.maxSequenceOfIdenticalCharacters) {\n constraints.add(\n new PasswordThreeConsecutiveCharactersNotAllowedConstraint(\n this.maxSequenceOfIdenticalCharacters\n )\n );\n }\n\n if (this.minNumberOfNumericCharacters) {\n constraints.add(\n new PasswordMinNumericCharactersConstraint(\n this.minNumberOfNumericCharacters\n )\n );\n }\n\n if (this.minNumberOfSpecialCharacters) {\n constraints.add(\n new PasswordMinSpecialCharactersConstraint(\n this.minNumberOfSpecialCharacters\n )\n );\n }\n\n if (this.regexConstraints && this.regexConstraints.length > 0) {\n this.regexConstraints.forEach((regexConstraint) => {\n constraints.add(new RegexConstraint(regexConstraint));\n });\n }\n\n if (\n this.layouthint.has(CONFIRM_PASSWORD) &&\n this.isConfirmPassword == null\n ) {\n constraints.add(\n new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)\n );\n }\n\n return constraints;\n }\n\n /**\n * Retrieve applicable constraint for this attribute\n */\n get constraintCollection(): ConstraintCollection {\n if (this.isConfirmPassword) {\n // confirm password only needs local constraints, no server constraints\n return this.getConfirmPasswordConstraints();\n }\n\n return super.constraintCollection;\n }\n\n /**\n */\n get isConfirmPassword(): boolean | null {\n return this._isConfirmPassword;\n }\n\n /**\n */\n set isConfirmPassword(isConfirmPassword: boolean) {\n this._isConfirmPassword = isConfirmPassword;\n }\n\n /**\n */\n get confirmValue(): string {\n return this._confirmValue || \"\";\n }\n\n /**\n */\n set confirmValue(confirmValue: string) {\n this._confirmValue = confirmValue;\n\n this.validate(this.inputvalue);\n }\n\n /**\n */\n get otherLabel(): string {\n return this._otherLabel;\n }\n\n /**\n */\n set otherLabel(otherLabel: string) {\n this._otherLabel = otherLabel;\n }\n\n /**\n * Validate input\n */\n validate(value: string): boolean {\n // when client side validation is disabled, this attribute is always valid\n if (!this.useClientsideValidation()) {\n return true;\n }\n\n if (this.isOptionalAndEmpty(value)) {\n this._isValid = true;\n } else if (this._validatedValue !== `${this.confirmValue}-${value}`) {\n this._isValid = this.constraintCollection.validate(value);\n }\n this._validatedValue = `${this.confirmValue}-${value}`;\n\n return this._isValid;\n }\n\n /**\n */\n getFormData(): { [string]: any } | null {\n if (this.isConfirmPassword || this.inError()) {\n return null;\n }\n\n return {\n [this.name]: this.value,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAIA;AACA;AACA;IACqBA,sB;;;;;;;;;;;;;;;;;;;;;;;;;;IAenB;AACF;IACE,eAAmB;MACjB,OAAO,UAAP;IACD;IAED;AACF;AACA;;;;WACE,gBAAOC,KAAP,EAA8C;MAC5C,KAAKC,sBAAL;MACA,KAAKC,UAAL,GAAkBF,KAAlB;MAEA,OAAO,IAAP;IACD;IAED;AACF;;;;SACE,eAA0B;MACxB,OAAO,KAAKG,eAAL,CAAqB,aAArB,EAAoC,EAApC,CAAP;IACD;IAED;AACF;;;;SACE,eAA2C;MACzC,OAAO,KAAKC,WAAL,CAAiBC,0BAAxB;IACD;IAED;AACF;;;;SACE,eAAgD;MAC9C,OAAO,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AAL,gDAA4B,KAAKpB,YAAjC,wBAAiDjB,KAAjD,CAAJ,EAA8D;QACnE,KAAKoC,QAAL,GAAgB,KAAKE,oBAAL,CAA0BN,QAA1B,CAAmChC,KAAnC,CAAhB;MACD;;MACD,KAAKqC,eAAL,8CAA0B,KAAKpB,YAA/B,wBAA+CjB,KAA/C;MAEA,OAAO,KAAKoC,QAAZ;IACD;IAED;AACF;;;;WACE,uBAAwC;MACtC,IAAI,KAAKzB,iBAAL,IAA0B,KAAK4B,OAAL,EAA9B,EAA8C;QAC5C,OAAO,IAAP;MACD;;MAED,yCACG,KAAKC,IADR,EACe,KAAKxC,KADpB;IAGD;;;;IA5ND;AACF;IACE,2BAAyByC,aAAzB,EAAyD;MACvD,IAAMd,UAAU,GAAGc,aAAH,aAAGA,aAAH,uBAAGA,aAAa,CAAEd,UAAlC;MACA,OACEc,aAAa,CAACC,IAAd,KAAuB,UAAvB,IACCC,KAAK,CAACC,OAAN,CAAcjB,UAAd,KAA6B,uBAAAA,UAAU,MAAV,CAAAA,UAAU,EAAU,UAAV,CAF1C;IAID;;;EAbiDkB,8B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.1",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "http://support.beinformed.com",
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
"react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0",
|
|
73
73
|
"react-helmet-async": "^1.0.0",
|
|
74
74
|
"react-redux": "^7.0.0 || ^8.0.0",
|
|
75
|
-
"react-router": "^5.
|
|
75
|
+
"react-router": "^5.0.0",
|
|
76
76
|
"redux": "^4.0.0",
|
|
77
|
-
"redux-thunk": "^2.
|
|
78
|
-
"styled-components": "^5.
|
|
77
|
+
"redux-thunk": "^2.0.0",
|
|
78
|
+
"styled-components": "^5.0.0"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@babel/runtime-corejs3": "^7.18.3",
|
|
@@ -135,20 +135,20 @@
|
|
|
135
135
|
"jest-sonar-reporter": "^2.0.0",
|
|
136
136
|
"jscodeshift": "^0.13.1",
|
|
137
137
|
"lint-staged": "^13.0.1",
|
|
138
|
-
"polished": "^4.
|
|
139
|
-
"prettier": "^2.7.
|
|
140
|
-
"react": "^18.
|
|
141
|
-
"react-dom": "^18.
|
|
142
|
-
"react-helmet-async": "^1.
|
|
143
|
-
"react-redux": "^8.0.
|
|
144
|
-
"react-router": "^5.
|
|
138
|
+
"polished": "^4.0.0",
|
|
139
|
+
"prettier": "^2.7.1",
|
|
140
|
+
"react": "^18.0.0",
|
|
141
|
+
"react-dom": "^18.0.0",
|
|
142
|
+
"react-helmet-async": "^1.0.0",
|
|
143
|
+
"react-redux": "^8.0.0",
|
|
144
|
+
"react-router": "^5.0.0",
|
|
145
145
|
"react-test-renderer": "^18.1.0",
|
|
146
|
-
"redux": "^4.
|
|
146
|
+
"redux": "^4.0.0",
|
|
147
147
|
"redux-mock-store": "^1.5.4",
|
|
148
|
-
"redux-thunk": "^2.
|
|
148
|
+
"redux-thunk": "^2.0.0",
|
|
149
149
|
"rimraf": "^3.0.2",
|
|
150
150
|
"standard-version": "^9.5.0",
|
|
151
|
-
"styled-components": "^5.
|
|
151
|
+
"styled-components": "^5.0.0",
|
|
152
152
|
"xhr-mock": "^2.5.1"
|
|
153
153
|
},
|
|
154
154
|
"scarfSettings": {
|
|
@@ -150,7 +150,10 @@ export default class PasswordAttributeModel extends StringAttributeModel {
|
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
if (
|
|
153
|
+
if (
|
|
154
|
+
this.layouthint.has(CONFIRM_PASSWORD) &&
|
|
155
|
+
this.isConfirmPassword == null
|
|
156
|
+
) {
|
|
154
157
|
constraints.add(
|
|
155
158
|
new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)
|
|
156
159
|
);
|
|
@@ -164,9 +167,8 @@ export default class PasswordAttributeModel extends StringAttributeModel {
|
|
|
164
167
|
*/
|
|
165
168
|
get constraintCollection(): ConstraintCollection {
|
|
166
169
|
if (this.isConfirmPassword) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return constraints;
|
|
170
|
+
// confirm password only needs local constraints, no server constraints
|
|
171
|
+
return this.getConfirmPasswordConstraints();
|
|
170
172
|
}
|
|
171
173
|
|
|
172
174
|
return super.constraintCollection;
|
|
@@ -174,8 +176,8 @@ export default class PasswordAttributeModel extends StringAttributeModel {
|
|
|
174
176
|
|
|
175
177
|
/**
|
|
176
178
|
*/
|
|
177
|
-
get isConfirmPassword(): boolean {
|
|
178
|
-
return this._isConfirmPassword
|
|
179
|
+
get isConfirmPassword(): boolean | null {
|
|
180
|
+
return this._isConfirmPassword;
|
|
179
181
|
}
|
|
180
182
|
|
|
181
183
|
/**
|