UNPKG

@microsoft.azure/autorest.incubator

Version:
43 lines 2.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const text_manipulation_1 = require("../../common/text-manipulation"); const clientruntime_1 = require("../../csharp/lowlevel-generator/clientruntime"); const primitive_1 = require("../../csharp/schema/primitive"); class Numeric extends primitive_1.Primitive { 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(property) { return ` ${this.validateMinimum(property)} ${this.validateMaximum(property)} ${this.validateExclusiveMinimum(property)} ${this.validateExclusiveMaximum(property)} ${this.validateMultipleOf(property)} `.trim(); } validateMinimum(property) { return this.schema.minimum && !this.schema.exclusiveMinimum ? `await listener.AssertIsGreaterThanOrEqual(${text_manipulation_1.nameof(property.value)},${property},${this.schema.minimum});` : ''; } validateMaximum(property) { return this.schema.maximum && !this.schema.exclusiveMaximum ? `await listener.AssertIsLessThanOrEqual(${text_manipulation_1.nameof(property.value)},${property},${this.schema.maximum});` : ''; } validateExclusiveMinimum(property) { return this.schema.minimum && this.schema.exclusiveMinimum ? `await listener.AssertIsGreaterThan(${text_manipulation_1.nameof(property.value)},${property},${this.schema.minimum});` : ''; } validateExclusiveMaximum(property) { return this.schema.maximum && this.schema.exclusiveMaximum ? `await listener.AssertIsLessThan(${text_manipulation_1.nameof(property.value)},${property},${this.schema.maximum});` : ''; } validateMultipleOf(property) { return this.schema.multipleOf ? `await listener.AssertIsMultipleOf(${text_manipulation_1.nameof(property.value)},${property},${this.schema.multipleOf});` : ''; } } exports.Numeric = Numeric; //# sourceMappingURL=integer.js.map