You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-07 10:46:24 +03:00
refactor to add Validation::final
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
@@ -38,13 +38,6 @@ export default class RoomAliasField extends React.PureComponent {
|
||||
return `#${localpart}:${this.props.domain}`;
|
||||
}
|
||||
|
||||
_isValid(value) {
|
||||
const fullAlias = this._asFullAlias(value);
|
||||
// XXX: FIXME https://github.com/matrix-org/matrix-doc/issues/668
|
||||
return !value.includes("#") && !value.includes(":") && !value.includes(",") &&
|
||||
encodeURI(fullAlias) === fullAlias;
|
||||
}
|
||||
|
||||
render() {
|
||||
const Field = sdk.getComponent('views.elements.Field');
|
||||
const poundSign = (<span>#</span>);
|
||||
@@ -87,7 +80,10 @@ export default class RoomAliasField extends React.PureComponent {
|
||||
if (!value) {
|
||||
return true;
|
||||
}
|
||||
return this._isValid(value);
|
||||
const fullAlias = this._asFullAlias(value);
|
||||
// XXX: FIXME https://github.com/matrix-org/matrix-doc/issues/668
|
||||
return !value.includes("#") && !value.includes(":") && !value.includes(",") &&
|
||||
encodeURI(fullAlias) === fullAlias;
|
||||
},
|
||||
invalid: () => _t("Some characters not allowed"),
|
||||
}, {
|
||||
@@ -96,7 +92,7 @@ export default class RoomAliasField extends React.PureComponent {
|
||||
invalid: () => _t("Please provide a room alias"),
|
||||
}, {
|
||||
key: "taken",
|
||||
skip: ({value}) => !value || !this._isValid(value),
|
||||
final: true,
|
||||
test: async ({value}) => {
|
||||
if (!value) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user