Skip to content

Commit

Permalink
fix: number fields precision for zero-scale
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed May 17, 2023
1 parent 41875fe commit 3e95454
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/commands/schema/generate/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type SaveableCustomField = Pick<
> & {
// TODO: get displayLocationInDecimal into jsforce2 typings
displayLocationInDecimal?: boolean;
type: typeof supportedFieldTypesCustomObject[number];
type: (typeof supportedFieldTypesCustomObject)[number];
};

export type FieldGenerateResult = {
Expand Down Expand Up @@ -175,11 +175,10 @@ export default class FieldGenerate extends SfCommand<FieldGenerateResult> {
{
type: 'number',
message: messages.getMessage('prompts.precision'),
validate: (n: number, answers: Response) =>
answers.scale ? integerValidation(n, 1, 18 - answers.scale) : undefined,
validate: (n: number, answers: Response) => integerValidation(n, 1, 18 - (answers.scale ?? 0)),
name: 'precision',
when: (answers: Response) => ['Number', 'Currency'].includes(answers.type),
default: (answers: Response) => (answers.scale ? 18 - answers.scale : undefined),
default: (answers: Response) => 18 - (answers.scale ?? 0),
},
// non-fieldtype-specific questions
descriptionPrompt,
Expand Down

0 comments on commit 3e95454

Please sign in to comment.