@opra/common
Version:
Opra common package
51 lines (50 loc) • 1.59 kB
JavaScript
import { __decorate, __metadata } from "tslib";
import { vg } from 'valgen';
import { DECODER, ENCODER } from '../../constants.js';
import { SimpleType } from '../simple-type.js';
let MobilePhoneType = class MobilePhoneType {
constructor(attributes) {
if (attributes)
Object.assign(this, attributes);
}
locale;
strictMode;
[DECODER](properties) {
return vg.isMobilePhone({
coerce: true,
locale: properties?.locale || 'any',
strictMode: properties?.strictMode ?? true,
});
}
[ENCODER](properties) {
return vg.isMobilePhone({
coerce: true,
locale: properties?.locale || 'any',
strictMode: properties?.strictMode ?? true,
});
}
};
__decorate([
SimpleType.Attribute({
description: 'Locale to use for validation',
}),
__metadata("design:type", String)
], MobilePhoneType.prototype, "locale", void 0);
__decorate([
SimpleType.Attribute({
description: 'If this is set to true, the mobile phone number must be supplied with the country code and therefore must start with +. Locale number',
}),
__metadata("design:type", Boolean)
], MobilePhoneType.prototype, "strictMode", void 0);
MobilePhoneType = __decorate([
SimpleType({
name: 'mobilephone',
description: 'A Mobile Phone Number value',
nameMappings: {
js: 'string',
json: 'string',
},
}),
__metadata("design:paramtypes", [Object])
], MobilePhoneType);
export { MobilePhoneType };