mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
Importing validators module from superset-ui (#9465)
* importing... this is going to break CI, but there it is. * adding validator package. * pluralization - maybe it should be plural, but whatevs * updating validators to match new exports * removing old validators * lintage ✨ * validateNumeric -> validateNumber * using legacyValidateInteger, legacyValidateNumber * linting ✨ * removing extraneous package lock file
This commit is contained in:
@@ -25,6 +25,7 @@ import { t } from '@superset-ui/translation';
|
||||
import { SupersetClient } from '@superset-ui/connection';
|
||||
import { getCategoricalSchemeRegistry } from '@superset-ui/color';
|
||||
import { getChartMetadataRegistry } from '@superset-ui/chart';
|
||||
import { validateNonEmpty } from '@superset-ui/validator';
|
||||
|
||||
import SelectControl from './SelectControl';
|
||||
import TextControl from './TextControl';
|
||||
@@ -40,7 +41,6 @@ import ANNOTATION_TYPES, {
|
||||
|
||||
import PopoverSection from '../../../components/PopoverSection';
|
||||
import ControlHeader from '../ControlHeader';
|
||||
import { nonEmpty } from '../../validators';
|
||||
import './AnnotationLayer.less';
|
||||
|
||||
const AUTOMATIC_COLOR = '';
|
||||
@@ -215,14 +215,18 @@ export default class AnnotationLayer extends React.PureComponent {
|
||||
timeColumn,
|
||||
intervalEndColumn,
|
||||
} = this.state;
|
||||
const errors = [nonEmpty(name), nonEmpty(annotationType), nonEmpty(value)];
|
||||
const errors = [
|
||||
validateNonEmpty(name),
|
||||
validateNonEmpty(annotationType),
|
||||
validateNonEmpty(value),
|
||||
];
|
||||
if (sourceType !== ANNOTATION_SOURCE_TYPES.NATIVE) {
|
||||
if (annotationType === ANNOTATION_TYPES.EVENT) {
|
||||
errors.push(nonEmpty(timeColumn));
|
||||
errors.push(validateNonEmpty(timeColumn));
|
||||
}
|
||||
if (annotationType === ANNOTATION_TYPES.INTERVAL) {
|
||||
errors.push(nonEmpty(timeColumn));
|
||||
errors.push(nonEmpty(intervalEndColumn));
|
||||
errors.push(validateNonEmpty(timeColumn));
|
||||
errors.push(validateNonEmpty(intervalEndColumn));
|
||||
}
|
||||
}
|
||||
errors.push(this.isValidFormula(value, annotationType));
|
||||
|
||||
@@ -19,7 +19,10 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormGroup, FormControl } from 'react-bootstrap';
|
||||
import * as v from '../../validators';
|
||||
import {
|
||||
legacyValidateNumber,
|
||||
legacyValidateInteger,
|
||||
} from '@superset-ui/validator';
|
||||
import ControlHeader from '../ControlHeader';
|
||||
|
||||
const propTypes = {
|
||||
@@ -51,7 +54,7 @@ export default class TextControl extends React.Component {
|
||||
// Validation & casting
|
||||
const errors = [];
|
||||
if (value !== '' && this.props.isFloat) {
|
||||
const error = v.numeric(value);
|
||||
const error = legacyValidateNumber(value);
|
||||
if (error) {
|
||||
errors.push(error);
|
||||
} else {
|
||||
@@ -59,7 +62,7 @@ export default class TextControl extends React.Component {
|
||||
}
|
||||
}
|
||||
if (value !== '' && this.props.isInt) {
|
||||
const error = v.integer(value);
|
||||
const error = legacyValidateInteger(value);
|
||||
if (error) {
|
||||
errors.push(error);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user