@opra/common
Version:
Opra common package
63 lines (62 loc) • 1.92 kB
JavaScript
import { __decorate, __metadata } from "tslib";
import { vg } from 'valgen';
import { DECODER, ENCODER } from '../../constants.js';
import { SimpleType } from '../simple-type.js';
const _isDateString = vg.isDateString({
precisionMin: 'tz',
coerce: true,
});
let DateTimeTypeTz = class DateTimeTypeTz {
constructor(attributes) {
if (attributes)
Object.assign(this, attributes);
}
[DECODER](properties) {
const fn = _isDateString;
const x = [fn];
if (properties.minValue != null) {
x.push(vg.isGte(fn(properties.minValue)));
}
if (properties.maxValue != null) {
x.push(vg.isLte(fn(properties.maxValue)));
}
return x.length > 0 ? vg.pipe(x, { returnIndex: 0 }) : fn;
}
[ENCODER](properties) {
const fn = _isDateString;
const x = [fn];
if (properties.minValue != null) {
x.push(vg.isGte(fn(properties.minValue)));
}
if (properties.maxValue != null) {
x.push(vg.isLte(fn(properties.maxValue)));
}
return x.length > 0 ? vg.pipe(x, { returnIndex: 0 }) : fn;
}
minValue;
maxValue;
};
__decorate([
SimpleType.Attribute({
description: 'Minimum value',
}),
__metadata("design:type", String)
], DateTimeTypeTz.prototype, "minValue", void 0);
__decorate([
SimpleType.Attribute({
description: 'Maximum value',
}),
__metadata("design:type", String)
], DateTimeTypeTz.prototype, "maxValue", void 0);
DateTimeTypeTz = __decorate([
(SimpleType({
name: 'datetimetz',
description: 'A full datetime value with time zone information',
nameMappings: {
js: 'string',
json: 'string',
},
}).Example('2021-04-18T22:30:15+03:00')),
__metadata("design:paramtypes", [Object])
], DateTimeTypeTz);
export { DateTimeTypeTz };