@beinformed/ui 1.18.8 → 1.18.9
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 +1 -1
- package/esm/models/attributes/PasswordAttributeModel.js.map +1 -1
- package/lib/models/attributes/PasswordAttributeModel.js +1 -1
- package/lib/models/attributes/PasswordAttributeModel.js.flow +1 -1
- package/lib/models/attributes/PasswordAttributeModel.js.map +1 -1
- package/package.json +2 -2
- package/src/models/attributes/PasswordAttributeModel.js +1 -1
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.18.9](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.18.8...v1.18.9) (2022-06-14)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **confirm-password:** only validate confirm-password with value ([9190faa](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/9190faa31e50e5a018003e478bcdad2a06b011ef))
|
|
10
|
+
|
|
5
11
|
### [1.18.8](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.18.7...v1.18.8) (2022-06-13)
|
|
6
12
|
|
|
7
13
|
### Bug Fixes
|
|
@@ -163,7 +163,7 @@ var PasswordAttributeModel = /*#__PURE__*/function (_StringAttributeModel) {
|
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
if (this.layouthint.has(CONFIRM_PASSWORD)) {
|
|
166
|
+
if (this.layouthint.has(CONFIRM_PASSWORD) && this.confirmValue !== "") {
|
|
167
167
|
constraints.add(new PasswordConfirmConstraint(this.confirmValue, this.otherLabel));
|
|
168
168
|
}
|
|
169
169
|
}
|
|
@@ -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","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 const constraints = new ConstraintCollection();\n\n if (this.isConfirmPassword) {\n constraints.add(\n new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)\n );\n } else {\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)) {\n constraints.add(\n new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)\n );\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,OAA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rC,KAAKS,aAAL,GAAqBT,YAArB;MAEA,KAAKU,QAAL,CAAc,KAAKrB,UAAnB;IACD;IAED;AACF;;;;SACE,eAAyB;MACvB,OAAO,KAAKsB,WAAZ;IACD;IAED;AACF;;SACE,aAAeV,UAAf,EAAmC;MACjC,KAAKU,WAAL,GAAmBV,UAAnB;IACD;IAED;AACF;AACA;;;;WACE,kBAASd,KAAT,EAAiC;MAAA;;MAC/B;MACA,IAAI,CAAC,KAAKyB,uBAAL,EAAL,EAAqC;QACnC,OAAO,IAAP;MACD;;MAED,IAAI,KAAKC,kBAAL,CAAwB1B,KAAxB,CAAJ,EAAoC;QAClC,KAAK2B,QAAL,GAAgB,IAAhB;MACD,CAFD,MAEO,IAAI,KAAKC,eAAL,mDAA4B,KAAKf,YAAjC,wBAAiDb,KAAjD,CAAJ,EAA8D;QACnE,KAAK2B,QAAL,GAAgB,KAAKE,oBAAL,CAA0BN,QAA1B,CAAmCvB,KAAnC,CAAhB;MACD;;MACD,KAAK4B,eAAL,iDAA0B,KAAKf,YAA/B,wBAA+Cb,KAA/C;MAEA,OAAO,KAAK2B,QAAZ;IACD;IAED;AACF;;;;WACE,uBAAwC;MACtC,IAAI,KAAKhB,iBAAL,IAA0B,KAAKmB,OAAL,EAA9B,EAA8C;QAC5C,OAAO,IAAP;MACD;;MAED,2BACG,KAAKC,IADR,EACe,KAAK/B,KADpB;IAGD;;;;IA3MD;AACF;IACE,2BAAyBgC,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;;;;EAbiD5B,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","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 const constraints = new ConstraintCollection();\n\n if (this.isConfirmPassword) {\n constraints.add(\n new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)\n );\n } else {\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\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,qCA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
|
|
188
188
|
|
|
189
|
-
if (this.layouthint.has(_LayoutHints.CONFIRM_PASSWORD)) {
|
|
189
|
+
if (this.layouthint.has(_LayoutHints.CONFIRM_PASSWORD) && this.confirmValue !== "") {
|
|
190
190
|
constraints.add(new _PasswordConfirmConstraint.default(this.confirmValue, this.otherLabel));
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -134,7 +134,7 @@ export default class PasswordAttributeModel extends StringAttributeModel {
|
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
if (this.layouthint.has(CONFIRM_PASSWORD)) {
|
|
137
|
+
if (this.layouthint.has(CONFIRM_PASSWORD) && this.confirmValue !== "") {
|
|
138
138
|
constraints.add(
|
|
139
139
|
new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)
|
|
140
140
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordAttributeModel.js","names":["PasswordAttributeModel","value","updateLastModification","inputvalue","getContribution","constraints","upperAndLowerCaseMandatory","maxSequenceOfIdenticalCharacters","maxSequenceOfUsernameCharacters","minNumberOfNumericCharacters","minNumberOfSpecialCharacters","regexConstraint","ConstraintCollection","isConfirmPassword","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 const constraints = new ConstraintCollection();\n\n if (this.isConfirmPassword) {\n constraints.add(\n new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)\n );\n } else {\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)) {\n constraints.add(\n new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)\n );\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;;;;SACE,eAA4C;MAC1C,OAAO,KAAKH,WAAL,CAAiBI,4BAAxB;IACD;IAED;AACF;;;;SACE,eAA4C;MAC1C,OAAO,KAAKJ,WAAL,CAAiBK,4BAAxB;IACD;IAED;AACF;;;;SACE,eAA4C;MAC1C,OAAO,KAAKL,WAAL,CAAiBM,eAAxB;IACD;IAED;AACF;AACA;;;;WACE,0BAAuC;MACrC,IAAMN,WAAW,GA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GA,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","ConstraintCollection","isConfirmPassword","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 const constraints = new ConstraintCollection();\n\n if (this.isConfirmPassword) {\n constraints.add(\n new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)\n );\n } else {\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\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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|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.9",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "http://support.beinformed.com",
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
"jscodeshift": "^0.13.1",
|
|
137
137
|
"lint-staged": "^13.0.1",
|
|
138
138
|
"polished": "^4.2.2",
|
|
139
|
-
"prettier": "^2.
|
|
139
|
+
"prettier": "^2.7.0",
|
|
140
140
|
"react": "^18.1.0",
|
|
141
141
|
"react-dom": "^18.1.0",
|
|
142
142
|
"react-helmet-async": "^1.3.0",
|
|
@@ -134,7 +134,7 @@ export default class PasswordAttributeModel extends StringAttributeModel {
|
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
if (this.layouthint.has(CONFIRM_PASSWORD)) {
|
|
137
|
+
if (this.layouthint.has(CONFIRM_PASSWORD) && this.confirmValue !== "") {
|
|
138
138
|
constraints.add(
|
|
139
139
|
new PasswordConfirmConstraint(this.confirmValue, this.otherLabel)
|
|
140
140
|
);
|