default_adapter.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * DevExtreme (ui/validation/default_adapter.js)
  3. * Version: 19.1.16
  4. * Build date: Tue Oct 18 2022
  5. *
  6. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  7. * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
  8. */
  9. "use strict";
  10. var Callbacks = require("../../core/utils/callbacks");
  11. var Class = require("../../core/class");
  12. var DefaultAdapter = Class.inherit({
  13. ctor: function(editor, validator) {
  14. var that = this;
  15. that.editor = editor;
  16. that.validator = validator;
  17. that.validationRequestsCallbacks = Callbacks();
  18. var handler = function(args) {
  19. that.validationRequestsCallbacks.fire(args)
  20. };
  21. editor.validationRequest.add(handler);
  22. editor.on("disposing", function() {
  23. editor.validationRequest.remove(handler)
  24. })
  25. },
  26. getValue: function() {
  27. return this.editor.option("value")
  28. },
  29. getCurrentValidationError: function() {
  30. return this.editor.option("validationError")
  31. },
  32. bypass: function() {
  33. return this.editor.option("disabled")
  34. },
  35. applyValidationResults: function(params) {
  36. this.editor.option({
  37. isValid: params.isValid,
  38. validationError: params.brokenRule
  39. })
  40. },
  41. reset: function() {
  42. this.editor.reset()
  43. },
  44. focus: function() {
  45. this.editor.focus()
  46. }
  47. });
  48. module.exports = DefaultAdapter;