#38: Implement messagesPerField existsError and get
This commit is contained in:
parent
392377bf2d
commit
92946ef6bb
@ -179,7 +179,49 @@
|
||||
</#attempt>
|
||||
})();
|
||||
}
|
||||
}
|
||||
},
|
||||
"existsError": function (key) {
|
||||
|
||||
<#attempt>
|
||||
|
||||
<#list profile.attributes as attribute>
|
||||
|
||||
if(key === "${attribute.name}" ){
|
||||
|
||||
return <#if messagesPerField.existsError('${attribute.name}')>true<#else>false</#if>;
|
||||
|
||||
}
|
||||
|
||||
</#list>
|
||||
|
||||
<#recover>
|
||||
</#attempt>
|
||||
|
||||
throw new Error(key + " is not an exsisting profile attribute name");
|
||||
|
||||
},
|
||||
"get": function (key) {
|
||||
|
||||
<#attempt>
|
||||
|
||||
<#list profile.attributes as attribute>
|
||||
|
||||
<#if messagesPerField.existsError('${attribute.name}')>
|
||||
|
||||
if(key === "${attribute.name}" ){
|
||||
return "${messagesPerField.get('${attribute.name}')?no_esc}"
|
||||
}
|
||||
|
||||
</#if>
|
||||
|
||||
</#list>
|
||||
|
||||
<#recover>
|
||||
</#attempt>
|
||||
|
||||
throw new Error(" there is no message for " + key);
|
||||
|
||||
}
|
||||
},
|
||||
"msg": function(){ throw new Error("use import { useKcMessage } from 'keycloakify'"); },
|
||||
"advancedMsg": function(){ throw new Error("use import { useKcMessage } from 'keycloakify'"); },
|
||||
|
@ -103,7 +103,7 @@ export declare namespace KcContextBase {
|
||||
registrationAction: string;
|
||||
};
|
||||
messagesPerField: {
|
||||
printIfExists<T>(
|
||||
printIfExists: <T>(
|
||||
key:
|
||||
"userLabel" |
|
||||
"username" |
|
||||
@ -113,7 +113,9 @@ export declare namespace KcContextBase {
|
||||
"password" |
|
||||
"password-confirm",
|
||||
x: T
|
||||
): T | undefined;
|
||||
)=> T | undefined;
|
||||
existsError: (key: string)=> boolean;
|
||||
get: (key: string) => string;
|
||||
};
|
||||
register: {
|
||||
formData: {
|
||||
|
@ -165,7 +165,9 @@ export const kcContextMocks: KcContextBase[] = [
|
||||
"registrationAction": "http://localhost:8080/auth/realms/myrealm/login-actions/registration?session_code=gwZdUeO7pbYpFTRxiIxRg_QtzMbtFTKrNu6XW_f8asM&execution=12146ce0-b139-4bbd-b25b-0eccfee6577e&client_id=account&tab_id=uS8lYfebLa0"
|
||||
},
|
||||
"messagesPerField": {
|
||||
"printIfExists": (...[, x]) => x
|
||||
"printIfExists": (...[, x]) => x,
|
||||
"existsError": ()=> true,
|
||||
"get": key=> `Fake error for ${key}`
|
||||
},
|
||||
"scripts": [],
|
||||
"isAppInitiatedAction": false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user