UNPKG

@opra/common

Version:

Opra common package

33 lines (32 loc) 1 kB
import { omitUndefined } from '@jsopen/objects'; import { OpraSchema } from '../../schema/index.js'; import { parseRegExp } from '../utils/parse-regexp.util.js'; import { HttpMediaType } from './http-media-type.js'; /** * * @class HttpMultipartField */ export class HttpMultipartField extends HttpMediaType { fieldName; fieldType; required; constructor(owner, initArgs) { super(owner, initArgs); this.fieldName = initArgs.fieldName instanceof RegExp ? initArgs.fieldName : initArgs.fieldName.startsWith('/') ? parseRegExp(initArgs.fieldName) : initArgs.fieldName; this.fieldType = initArgs.fieldType; this.required = initArgs.required; } toJSON(options) { return omitUndefined({ fieldName: this.fieldName, fieldType: this.fieldType, required: this.required, ...super.toJSON(options), }); } }