Cli-microsoft365: Enhancement: Add theme palette JSON validation to 'spo theme set' command

Created on 9 Apr 2020  路  2Comments  路  Source: pnp/cli-microsoft365

Raised from #1463

We should add some validation into the command to check the incoming JSON and throw an error if invalid before we send it to the API, as currently when sending invalid template palette (as detailed in the referenced issue), no error is thrown so the CLI gives a false positive.

A valid template is as follows

{
    "themePrimary": "#d81e05",
    "themeLighterAlt": "#fdf5f4",
    "themeLighter": "#f9d6d2",
    "themeLight": "#f4b4ac",
    "themeTertiary": "#e87060",
    "themeSecondary": "#dd351e",
    "themeDarkAlt": "#c31a04",
    "themeDark": "#a51603",
    "themeDarker": "#791002",
    "neutralLighterAlt": "#eeeeee",
    "neutralLighter": "#f5f5f5",
    "neutralLight": "#e1e1e1",
    "neutralQuaternaryAlt": "#d1d1d1",
    "neutralQuaternary": "#c8c8c8",
    "neutralTertiaryAlt": "#c0c0c0",
    "neutralTertiary": "#c2c2c2",
    "neutralSecondary": "#858585",
    "neutralPrimaryAlt": "#4b4b4b",
    "neutralPrimary": "#333333",
    "neutralDark": "#272727",
    "black": "#1d1d1d",
    "white": "#f5f5f5"
}

Validation checks the following:

  • [x] the specified string is a valid JSON string
  • [x] the deserialized object contains all properties defined in the above example
  • [x] the deserialized object doesn't contain any other properties
  • [x] each property of the deserialized object contains a valid hex color value prefixed with a #
enhancement work in progress

Most helpful comment

I'll take a look at this one 馃槉

All 2 comments

I've extended the spec with which checks the validation should to, to clarify the expectations

I'll take a look at this one 馃槉

Was this page helpful?
0 / 5 - 0 ratings