#38: Implement messagesPerField existsError and get
This commit is contained in:
parent
392377bf2d
commit
92946ef6bb
@ -179,6 +179,48 @@
|
|||||||
</#attempt>
|
</#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'"); },
|
"msg": function(){ throw new Error("use import { useKcMessage } from 'keycloakify'"); },
|
||||||
|
@ -103,7 +103,7 @@ export declare namespace KcContextBase {
|
|||||||
registrationAction: string;
|
registrationAction: string;
|
||||||
};
|
};
|
||||||
messagesPerField: {
|
messagesPerField: {
|
||||||
printIfExists<T>(
|
printIfExists: <T>(
|
||||||
key:
|
key:
|
||||||
"userLabel" |
|
"userLabel" |
|
||||||
"username" |
|
"username" |
|
||||||
@ -113,7 +113,9 @@ export declare namespace KcContextBase {
|
|||||||
"password" |
|
"password" |
|
||||||
"password-confirm",
|
"password-confirm",
|
||||||
x: T
|
x: T
|
||||||
): T | undefined;
|
)=> T | undefined;
|
||||||
|
existsError: (key: string)=> boolean;
|
||||||
|
get: (key: string) => string;
|
||||||
};
|
};
|
||||||
register: {
|
register: {
|
||||||
formData: {
|
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"
|
"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": {
|
"messagesPerField": {
|
||||||
"printIfExists": (...[, x]) => x
|
"printIfExists": (...[, x]) => x,
|
||||||
|
"existsError": ()=> true,
|
||||||
|
"get": key=> `Fake error for ${key}`
|
||||||
},
|
},
|
||||||
"scripts": [],
|
"scripts": [],
|
||||||
"isAppInitiatedAction": false,
|
"isAppInitiatedAction": false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user