@salte-auth/salte-auth
Version:
Authentication for the modern web!
31 lines (25 loc) • 684 B
text/typescript
import { SalteAuthError } from './salte-auth-error';
export class Required {
public constructor(config?: Required.Config) {
this.config = config || {};
}
protected required(...keys: string[]): void {
const missing = keys.filter((key: string) => {
return this.config[key] === undefined;
});
if (missing.length > 0) {
throw new SalteAuthError({
code: 'missing_required_properties',
message: `Missing the following required fields. (${missing.join(', ')})`,
});
}
}
}
export interface Required {
config: Required.Config;
};
export declare namespace Required {
export interface Config {
[key: string]: any;
}
}