@6thquake/react-material
Version:
React components that implement Google's Material Design.
18 lines (13 loc) • 470 B
JavaScript
import { addValidationRule } from 'formsy-react';
const hasValue = value => {
return !(typeof value === 'undefined' || value === null || value === '');
}; // required
addValidationRule('isRequired', (values, value) => {
return hasValue(value);
}); // 最小值
addValidationRule('min', (values, value, v) => {
return !hasValue(value) || value >= v;
}); // 最大值
addValidationRule('max', (values, value, v) => {
return !hasValue(value) || value <= v;
});