Resolve seen issue regarding destroyed validation context (#19359)
maybe messages has been destroyed so enable it to be undefined
This commit is contained in:
@@ -31,7 +31,7 @@ export class UmbBindServerValidationToFormControl extends UmbControllerBase {
|
||||
this.#value = value;
|
||||
// Only remove server validations from validation context [NL]
|
||||
const toRemove = this.#messages.filter((x) => x.type === 'server').map((msg) => msg.key);
|
||||
this.#context?.messages.removeMessageByKeys(toRemove);
|
||||
this.#context?.messages?.removeMessageByKeys(toRemove);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export class UmbFormControlValidator extends UmbControllerBase implements UmbVal
|
||||
this.#context = context;
|
||||
context?.addValidator(this);
|
||||
// If we have a message already, then un-pristine the control:
|
||||
if (dataPath && context?.messages.getHasMessagesOfPathAndDescendant(dataPath)) {
|
||||
if (dataPath && context?.messages?.getHasMessagesOfPathAndDescendant(dataPath)) {
|
||||
formControl.pristine = false;
|
||||
}
|
||||
});
|
||||
@@ -46,11 +46,11 @@ export class UmbFormControlValidator extends UmbControllerBase implements UmbVal
|
||||
|
||||
if (this.#dataPath) {
|
||||
if (newVal) {
|
||||
this.#context?.messages.removeMessagesByTypeAndPath('client', this.#dataPath);
|
||||
this.#context?.messages?.removeMessagesByTypeAndPath('client', this.#dataPath);
|
||||
} else {
|
||||
// We only want to add the message if it is not already there. (this could be a custom or server message that got binded to the control, we do not want that double.)
|
||||
if (!this.#context?.messages.getHasMessageOfPathAndBody(this.#dataPath, this.#control.validationMessage)) {
|
||||
this.#context?.messages.addMessage('client', this.#dataPath, this.#control.validationMessage);
|
||||
if (!this.#context?.messages?.getHasMessageOfPathAndBody(this.#dataPath, this.#control.validationMessage)) {
|
||||
this.#context?.messages?.addMessage('client', this.#dataPath, this.#control.validationMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ export class UmbValidationController extends UmbControllerBase implements UmbVal
|
||||
>;
|
||||
#inUnprovidingState: boolean = false;
|
||||
|
||||
// @reprecated - Will be removed in v.17
|
||||
// @deprecated - Will be removed in v.17
|
||||
// Local version of the data send to the server, only use-case is for translation.
|
||||
#translationData = new UmbObjectState<any>(undefined);
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ export class UmbValidationController extends UmbControllerBase implements UmbVal
|
||||
setVariantId(variantId: UmbVariantId): void {
|
||||
this.#variantId = variantId;
|
||||
// @.culture == null && @.segment == null
|
||||
this.messages.filter((msg) => {
|
||||
this.messages?.filter((msg) => {
|
||||
// Figure out how many times '@.culture ==' is present in the path:
|
||||
//const cultureMatches = (msg.path.match(/@\.culture ==/g) || []);
|
||||
// I like a Regex that finds all the @.culture == and @.segment == in the path. they are adjacent. and I like to know the value following '== '
|
||||
@@ -113,7 +113,7 @@ export class UmbValidationController extends UmbControllerBase implements UmbVal
|
||||
* @param translator
|
||||
*/
|
||||
async addTranslator(translator: UmbValidationMessageTranslator) {
|
||||
this.messages.addTranslator(translator);
|
||||
this.messages?.addTranslator(translator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user