Co-authored-by: SANDEEP KUMAR <sandeep.ku@navi.com> Co-authored-by: Somarapu Vamshi <somarapu.vamshi@navi.com> Co-authored-by: Shivam Goyal <shivam.goyal@navi.com> Co-authored-by: vedant aggarwal <vedant.aggarwal@navi.com> Co-authored-by: Mehul Garg <mehul.garg@navi.com> Co-authored-by: Hardik Chaudhary <hardik.chaudhary@navi.com> Co-authored-by: Aditya Narayan Malik <aditya.narayan@navi.com> Co-authored-by: Shaurya Rehan <shaurya.rehan@navi.com> Co-authored-by: Divyesh Shinde <divyesh.shinde@navi.com> Co-authored-by: Mohit Rajput <mohit.rajput@navi.com> Co-authored-by: sharmapoojabalrambhai <sharma.balrambhai@navi.com> Co-authored-by: Prajjaval Verma <prajjaval.verma@navi.com>
16 lines
481 B
TypeScript
16 lines
481 B
TypeScript
export const isValidHexColor = (color: string) =>
|
|
/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(color);
|
|
|
|
export const isValidHexColors = (
|
|
colorArray: string[] | undefined,
|
|
defaultColorsArray?: string[],
|
|
) => {
|
|
if (colorArray && Array.isArray(colorArray) && colorArray.length > 0) {
|
|
const isValidColors = colorArray.every(isValidHexColor);
|
|
if (isValidColors) {
|
|
return colorArray;
|
|
}
|
|
}
|
|
return defaultColorsArray || ["#FFFFFF", "#FFFFFF"];
|
|
};
|