@autorest/powershell
Version:
AutoRest PowerShell Cmdlet Generator
48 lines • 2.65 kB
JavaScript
;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.Numeric = void 0;
const codegen_1 = require("@azure-tools/codegen");
const clientruntime_1 = require("../clientruntime");
const primitive_1 = require("./primitive");
class Numeric extends primitive_1.NewPrimitive {
constructor(schema, isRequired, numericType) {
super(schema);
this.isRequired = isRequired;
this.numericType = numericType;
this.isXmlAttribute = false;
this.jsonType = clientruntime_1.ClientRuntime.JsonNumber;
}
get declaration() {
return `${this.numericType}`;
}
validateValue(eventListener, property) {
return `
${this.validateMinimum(eventListener, property)}
${this.validateMaximum(eventListener, property)}
${this.validateExclusiveMinimum(eventListener, property)}
${this.validateExclusiveMaximum(eventListener, property)}
${this.validateMultipleOf(eventListener, property)}
`.trim();
}
validateMinimum(eventListener, property) {
return this.schema.minimum && !this.schema.exclusiveMinimum ? `await ${eventListener}.AssertIsGreaterThanOrEqual(${(0, codegen_1.nameof)(property.value)},${property},${this.schema.minimum});` : '';
}
validateMaximum(eventListener, property) {
return this.schema.maximum && !this.schema.exclusiveMaximum ? `await ${eventListener}.AssertIsLessThanOrEqual(${(0, codegen_1.nameof)(property.value)},${property},${this.schema.maximum});` : '';
}
validateExclusiveMinimum(eventListener, property) {
return this.schema.minimum && this.schema.exclusiveMinimum ? `await ${eventListener}.AssertIsGreaterThan(${(0, codegen_1.nameof)(property.value)},${property},${this.schema.minimum});` : '';
}
validateExclusiveMaximum(eventListener, property) {
return this.schema.maximum && this.schema.exclusiveMaximum ? `await ${eventListener}.AssertIsLessThan(${(0, codegen_1.nameof)(property.value)},${property},${this.schema.maximum});` : '';
}
validateMultipleOf(eventListener, property) {
return this.schema.multipleOf ? `await ${eventListener}.AssertIsMultipleOf(${(0, codegen_1.nameof)(property.value)},${property},${this.schema.multipleOf});` : '';
}
}
exports.Numeric = Numeric;
//# sourceMappingURL=integer.js.map