@theia/core
Version:
Theia is a cloud & desktop IDE framework implemented in TypeScript.
58 lines • 3.41 kB
TypeScript
import { PreferenceItem } from '../../common/preferences/preference-schema';
import { JSONObject, JSONValue } from '../../../shared/@phosphor/coreutils';
import { PreferenceSchemaProvider } from './preference-contribution';
import { PreferenceLanguageOverrideService } from './preference-language-override-service';
import { IJSONSchema, JsonType } from '../../common/json-schema';
export interface PreferenceValidator<T> {
name: string;
validate(value: unknown): T;
}
export interface ValidatablePreference extends IJSONSchema, Pick<PreferenceItem, 'defaultValue'> {
}
export declare type ValueValidator = (value: JSONValue) => JSONValue;
export interface PreferenceValidationResult<T extends JSONValue> {
original: JSONValue | undefined;
valid: T;
messages: string[];
}
declare type ValidatablePreferenceTuple = ValidatablePreference & ({
items: ValidatablePreference[];
} | {
prefixItems: ValidatablePreference[];
});
export declare class PreferenceValidationService {
protected readonly schemaProvider: PreferenceSchemaProvider;
protected readonly languageOverrideService: PreferenceLanguageOverrideService;
validateOptions(options: Record<string, JSONValue>): Record<string, JSONValue>;
validateByName(preferenceName: string, value: JSONValue): JSONValue;
protected doValidateByName(preferenceName: string, value: JSONValue): JSONValue;
validateBySchema(key: string, value: JSONValue, schema: ValidatablePreference | undefined): JSONValue;
protected getSchema(name: string): ValidatablePreference | undefined;
protected validateMultiple(key: string, value: JSONValue, schema: ValidatablePreference & {
type: JsonType[];
}): JSONValue;
protected validateAnyOf(key: string, value: JSONValue, schema: ValidatablePreference & {
anyOf: ValidatablePreference[];
}): JSONValue;
protected validateOneOf(key: string, value: JSONValue, schema: ValidatablePreference & {
oneOf: ValidatablePreference[];
}): JSONValue;
protected mapValidators(key: string, value: JSONValue, validators: Iterable<(value: JSONValue) => JSONValue>): JSONValue;
protected validateArray(key: string, value: JSONValue, schema: ValidatablePreference): JSONValue[];
protected validateTuple(key: string, value: JSONValue, schema: ValidatablePreferenceTuple): JSONValue[];
protected validateConst(key: string, value: JSONValue, schema: ValidatablePreference & {
const: JSONValue;
}): JSONValue;
protected validateEnum(key: string, value: JSONValue, schema: ValidatablePreference & {
enum: JSONValue[];
}): JSONValue;
protected validateBoolean(key: string, value: JSONValue, schema: ValidatablePreference): boolean;
protected validateInteger(key: string, value: JSONValue, schema: ValidatablePreference): number;
protected validateNumber(key: string, value: JSONValue, schema: ValidatablePreference): number;
protected validateObject(key: string, value: JSONValue, schema: ValidatablePreference): JSONObject;
protected objectMatchesSchema(key: string, value: JSONValue, schema: ValidatablePreference): value is JSONObject;
protected validateString(key: string, value: JSONValue, schema: ValidatablePreference): string;
protected getDefaultFromSchema(schema: ValidatablePreference): JSONValue;
}
export {};
//# sourceMappingURL=preference-validation-service.d.ts.map