mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 17:43:35 -06:00
12 lines
349 B
TypeScript
12 lines
349 B
TypeScript
import { ValidationRule } from 'app/types';
|
|
|
|
export const validate = (value: string, validationRules: ValidationRule[]) => {
|
|
const errors = validationRules.reduce((acc, currRule) => {
|
|
if (!currRule.rule(value)) {
|
|
return acc.concat(currRule.errorMessage);
|
|
}
|
|
return acc;
|
|
}, []);
|
|
return errors.length > 0 ? errors : null;
|
|
};
|