JSFiddle - React, Tailwind, and code Playground

by vaibhav2812

JavaScript

const policy = {
  "maxPasswordAge": 0,
  "minimumPasswordLength": 10,
  "maximumPasswordLength": 50,
  "complexity": true,
  "memory": 0,
  "trackLoginInfo": true,
  "allowedLoginAttempt": 0,
  "resetPassword": false,
  "disableAccount": false,
  "defaultMailAddress": "",
  "allowedSpecialChar": "&,*,(,),$,%,^,#,@",
  "newPwdChangeDays": 0,
  "remindPwdChange": 7,
  "policyEnabled": true,
  "generatePasswordOnExpiry": false,
  "forceChangePasswordOnExpiry": false
}

const note = [{
    "id": 1,
    "optKey": "minimumPasswordLength",
    "description": "Password should contain minimum of [minimumPasswordLength]characters.",
    "caption": "Minimum Password Length",
    "sortOrder": 1
  },
  {
    "id": 2,
    "optKey": "maximumPasswordLength",
    "description": "Password should contain maximum of [maximumPasswordLength] characters.",
    "caption": "Maximum Password Length",
    "sortOrder": 2
  },
  {
    "id": 3,
    "optKey": "allowedSpecialChar",
    "description": "Password should contain at least one of the following special characters [allowedSpecialChar].",
    "caption": "Allowed Special Characters In Password",
    "sortOrder": 3
  },
  {
    "id": 4,
    "optKey": "memory",
    "description": "You cannot reuse your previous [memory] passwords.",
    "caption": "Memory List Size",
    "sortOrder": 4
  },
  {
    "id": 5,
    "optKey": "maxPasswordAge",
    "description": "Password will expire after [maxPasswordAge] days from the date of password change.Please change your password before [maxPasswordAge] days.",
    "caption": "Password Expiry Limit",
    "sortOrder": 5
  },
  {
    "id": 6,
    "optKey": "newPwdChangeDays",
    "description": "You can again change your password after [newPwdChangeDays] days",
    "caption": "Minimum Password Change Gap",
    "sortOrder": 6
  }
];
 var result = note.reduce((model, item)=>{
const replacementObj = Object.keys(policy).find((f) => f === item.optKey);
 const description =...