-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error if required schematic properties without defaults are not provided #12167
Comments
From @ssilvert on January 10, 2018 15:45 I was just about to report this. It works fine for me if the schematic is run with the "schematics" tool. However, if the schematic is run from "ng" it ignores required properties. schematics @Mystuff:myschematic <-- throws error if required prop not specified ng g myschematic --collection @Mystuff <-- ignores required props IMO, this is a BUG and not a feature request. |
This still appears to reproduce on the latest version. Initialized a new schematic with: $ schematics blank --name test-schematic Then added {
"properties": {
"name": {
"type": "string",
"minLength": 1
}
},
"required": [ "name" ]
} This requires a single import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
export function testSchematic(_options: any): Rule {
return (tree: Tree, _context: SchematicContext) => {
_context.logger.info('The name is', _options.name);
return tree;
};
} And ran with:
Definitely should throw an error in such a case.
|
Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version. If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
From @dansanderson on June 14, 2017 18:15
Currently if a schematic property is in schema.json's "required" list, nothing different happens if the option is not provided on the command line and doesn't have a "default". It should report a user error in this case.
Copied from original issue: angular/devkit#6
The text was updated successfully, but these errors were encountered: