don't show "This alias is available to use" if an alias is not provided
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
0c4897a875
commit
86a1327259
2 changed files with 9 additions and 1 deletions
|
@ -92,6 +92,7 @@ export default class RoomAliasField extends React.PureComponent {
|
||||||
invalid: () => _t("Please provide a room alias"),
|
invalid: () => _t("Please provide a room alias"),
|
||||||
}, {
|
}, {
|
||||||
key: "taken",
|
key: "taken",
|
||||||
|
skip: ({value}) => !value,
|
||||||
test: async ({value}) => {
|
test: async ({value}) => {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -51,9 +51,16 @@ export default function withValidation({ description, rules }) {
|
||||||
if (!rule.key || !rule.test) {
|
if (!rule.key || !rule.test) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const data = { value, allowEmpty };
|
||||||
|
|
||||||
|
if (rule.skip && rule.skip.call(this, data)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// We're setting `this` to whichever component holds the validation
|
// We're setting `this` to whichever component holds the validation
|
||||||
// function. That allows rules to access the state of the component.
|
// function. That allows rules to access the state of the component.
|
||||||
const ruleValid = await rule.test.call(this, { value, allowEmpty });
|
const ruleValid = await rule.test.call(this, data);
|
||||||
valid = valid && ruleValid;
|
valid = valid && ruleValid;
|
||||||
if (ruleValid && rule.valid) {
|
if (ruleValid && rule.valid) {
|
||||||
// If the rule's result is valid and has text to show for
|
// If the rule's result is valid and has text to show for
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue