huridocs/uwazi

View on GitHub
app/react/Documents/utils/documentValidator.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
export function required(val) {
  return val.trim() !== '';
}

export default {
  generate(template) {
    const validationObject = {
      title: { required },
    };

    template.properties.forEach(property => {
      if (property.required) {
        validationObject[`metadata.${property.name}`] = { required };
      }
    });

    return validationObject;
  },
};