UNPKG

fk-react-ui-components

Version:

Step 1 : Create a file in [ Seeds / Plants / Trees ] <br> Step 2 : It should export an Object with component name and story Component [Refer other components] <br> Step 3 : Story Component should return a react component <br> Step 3 : Created file should

30 lines (27 loc) 802 B
import * as validators from 'valid.js'; // Please refer https://github.com/dleitee/valid.js for documentation let isNil = value => !value; validators["validate"] = (...fnArr) => value => { let errorObj = { isValid: true, message: "" }; if (!value) { value = ""; } return fnArr.reduce((acc, x) => { if (isNil(x.fn)) { throw new Error('The function for validation is null or undefined.'); } else { if (acc.isValid && !x.fn(value)) { return { isValid: false, message: x.message || "Validation Failure" }; } return acc; } }, errorObj, fnArr); }; export default validators; //# sourceMappingURL=Validator.js.map