validate-options.js 463 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. /*
  3. Copyright 2019 Google LLC
  4. Use of this source code is governed by an MIT-style
  5. license that can be found in the LICENSE file or at
  6. https://opensource.org/licenses/MIT.
  7. */
  8. module.exports = (options, schema) => {
  9. const {
  10. value,
  11. error
  12. } = schema.validate(options, {
  13. language: {
  14. object: {
  15. allowUnknown: 'is not a supported parameter.'
  16. }
  17. }
  18. });
  19. if (error) {
  20. throw error;
  21. }
  22. return value;
  23. };