@gitlab/ui
Version:
GitLab UI Components
17 lines (15 loc) • 525 B
JavaScript
// This contains core validating behavior and **should not** contain
// domain-specific validations.
//
// Look to what's allowed in HTML attributes as a good basis for what belongs here
//
// ```
// // Good
// export const required = ...
//
// // Bad
// export const projectPathIsUnique = ...
// ```
const factory = (failMessage, isValid) => val => !isValid(val) ? failMessage : '';
const required = failMessage => factory(failMessage, val => val !== '' && val !== null && val !== undefined);
export { factory, required };