UNPKG

@schematics/angular

Version:
65 lines (64 loc) 2.8 kB
{ "$schema": "http://json-schema.org/draft-07/schema", "$id": "SchematicsAngularGuard", "title": "Angular Guard Options Schema", "type": "object", "description": "Creates a new route guard in your project. Route guards are used to control access to parts of your application by checking certain conditions before a route is activated. This schematic generates a new guard with the specified name, type, and options.", "additionalProperties": false, "properties": { "name": { "type": "string", "description": "The name for the new route guard. This will be used to create the guard's class and spec files (e.g., `my-guard.guard.ts` and `my-guard.guard.spec.ts`).", "$default": { "$source": "argv", "index": 0 }, "x-prompt": "What name would you like to use for the guard?" }, "skipTests": { "type": "boolean", "description": "Skip the generation of a unit test file `spec.ts` for the new guard.", "default": false }, "flat": { "type": "boolean", "description": "Creates the new guard files at the top level of the current project. If set to false, a new folder with the guard's name will be created to contain the files.", "default": true }, "path": { "type": "string", "format": "path", "$default": { "$source": "workingDirectory" }, "description": "The path where the guard files should be created, relative to the current workspace. If not provided, the guard will be created in the current directory.", "visible": false }, "project": { "type": "string", "description": "The name of the project where the guard should be created. If not specified, the CLI will determine the project from the current directory.", "$default": { "$source": "projectName" } }, "functional": { "type": "boolean", "description": "Generate the guard as a function instead of a class. Functional guards can be simpler for basic scenarios.", "default": true }, "implements": { "alias": "guardType", "type": "array", "description": "Specifies the type(s) of guard to create. You can choose one or more of the following: `CanActivate` (controls access to a route), `CanActivateChild` (controls access to child routes), `CanDeactivate` (asks for confirmation before leaving a route), `CanMatch` (determines if a route can be matched).", "uniqueItems": true, "minItems": 1, "items": { "enum": ["CanActivate", "CanActivateChild", "CanDeactivate", "CanMatch"], "type": "string" }, "default": ["CanActivate"], "x-prompt": "Which type of guard would you like to create?" } }, "required": ["name", "project"] }