Commit ededc8d2 authored by Diegodlh's avatar Diegodlh
Browse files

Update Domain's translate method parameters

* make "domain" the only required parameter
* make all other parameters optional and named
* use default fallback template definition
* allow changing the force-required fields
parent 4072efda
......@@ -17,6 +17,7 @@ import {
} from "../types";
import { isDomainName } from "../utils";
import { DomainNameError } from "../errors";
import { fallbackTemplate as fallbackTemplateDefinition } from "../fallbackTemplate";
export class Domain {
readonly domain: string;
......@@ -25,13 +26,19 @@ export class Domain {
// tests: TestConfiguration;
constructor(
domain: string,
definition: {
{
templates,
patterns,
fallbackTemplate = fallbackTemplateDefinition,
catchallPattern = true,
forceRequiredFields = config.forceRequiredFields,
}: {
templates?: Array<TemplateDefinition>;
patterns?: Array<PatternDefinition>;
// tests?: Array<Object>,
} = {},
fallbackTemplate?: FallbackTemplateDefinition,
catchallPattern = true
fallbackTemplate?: FallbackTemplateDefinition;
catchallPattern?: boolean;
forceRequiredFields?: FieldName[];
} = {}
) {
if (isDomainName(domain)) {
this.domain = domain;
......@@ -40,15 +47,11 @@ export class Domain {
}
this.templates = new TemplateConfiguration(
domain,
config.forceRequiredFields,
forceRequiredFields,
fallbackTemplate,
definition.templates
);
this.patterns = new PatternConfiguration(
domain,
definition.patterns,
catchallPattern
templates
);
this.patterns = new PatternConfiguration(domain, patterns, catchallPattern);
}
async translate(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment