mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
31 lines
584 B
TypeScript
31 lines
584 B
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import yaml from "js-yaml";
|
|
|
|
export interface MonacoValidator {
|
|
(value: string): void;
|
|
}
|
|
|
|
export function yamlValidator(value: string) {
|
|
try {
|
|
yaml.loadAll(value);
|
|
} catch (error) {
|
|
throw String(error);
|
|
}
|
|
}
|
|
|
|
export function jsonValidator(value: string) {
|
|
try {
|
|
JSON.parse(value);
|
|
} catch (error) {
|
|
throw String(error);
|
|
}
|
|
}
|
|
|
|
export const monacoValidators = {
|
|
yaml: yamlValidator,
|
|
json: jsonValidator,
|
|
};
|