This is an automated email from the ASF dual-hosted git repository.

thiagohp pushed a commit to branch feature/coffeescript-to-typescript
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git

commit 011f6b0276660690483e139e361591716ee39a6e
Author: Thiago H. de Paula Figueiredo <thi...@arsmachina.com.br>
AuthorDate: Sat Apr 19 16:36:34 2025 -0300

    TAP5-2804: tapestry-beanvalidator cleanup
---
 tapestry-beanvalidator/build.gradle                |  12 --
 .../t5/beanvalidator/beanvalidator-validation.ts   | 124 ++++++++++-----------
 2 files changed, 62 insertions(+), 74 deletions(-)

diff --git a/tapestry-beanvalidator/build.gradle 
b/tapestry-beanvalidator/build.gradle
index 47f4aeefb..7c20eb3ea 100644
--- a/tapestry-beanvalidator/build.gradle
+++ b/tapestry-beanvalidator/build.gradle
@@ -17,10 +17,6 @@ dependencies {
 
 }
 
-task compileCoffeeScript(type: CompileCoffeeScript) {
-    outputDir "src/main/generated/compiled-coffeescript"
-}
-
 // Start up the test app, useful when debugging failing integration tests
 task runTestApp303(type:JavaExec) {
   main = 'org.apache.tapestry5.test.JettyRunner'
@@ -28,12 +24,4 @@ task runTestApp303(type:JavaExec) {
   classpath += project.sourceSets.test.runtimeClasspath
 }
 
-clean.delete 'src/main/generated'
-
-sourceSets {
-    main {
-        output.dir(compileCoffeeScript.outputDir, builtBy: compileCoffeeScript)
-    }
-}
-
 jar.manifest.attributes 'Tapestry-Module-Classes': 
'org.apache.tapestry5.beanvalidator.modules.BeanValidatorModule'
diff --git 
a/tapestry-core/src/main/typescript/src/t5/beanvalidator/beanvalidator-validation.ts
 
b/tapestry-core/src/main/typescript/src/t5/beanvalidator/beanvalidator-validation.ts
index d8a114bff..b1aecfb4e 100644
--- 
a/tapestry-core/src/main/typescript/src/t5/beanvalidator/beanvalidator-validation.ts
+++ 
b/tapestry-core/src/main/typescript/src/t5/beanvalidator/beanvalidator-validation.ts
@@ -1,9 +1,4 @@
-/*
- * decaffeinate suggestions:
- * DS102: Remove unnecessary code created because of implicit returns
- * Full docs: 
https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
- */
-// Copyright 2012-2013 The Apache Software Foundation
+// Copyright 2012-2025 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -17,70 +12,75 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-// ## t5/beanvalidator/beanvalidator-validation
-//
-// The awkward name is to accomidate the "docco" documentation tool; it 
doesn't understand
-// having the same named file in multiple folders. See 
https://github.com/jashkenas/docco/issues/201.
-//
-// Supports extra validations related to the beanvalidator module.
-define(["underscore", "t5/core/dom", "t5/core/events", "t5/core/utils", 
"t5/core/validation"],
-  function(_, dom, events, utils) {
-
-    const rangeValue = function(element, attribute, defaultValue) {
-      const v = element.attr(attribute);
-      if (v === null) {
-        return defaultValue;
-      } else {
-        return parseInt(v);
-      }
-    };
-
-    const countOptions = function(e) {
-      // A select that is used as part of a palette is different; the 
validation attributes
-      // are attached to the selected (right side) <select>, and anything 
there counts as part
-      // of the selection.
-      if (e.findParent(".palette")) {
-        return e.element.options.length;
-      } else {
-        // An ordinary <select> may have multiple options (the clumsy 
control-click way)
-        return _.filter(e.element.options, o => o.selected).length;
-      }
-    };
+/**
+ * 
+ * ## t5/beanvalidator/beanvalidator-validation
+ *
+ * The awkward name is to accomidate the "docco" documentation tool; it 
doesn't understand
+ * having the same named file in multiple folders. See 
https://github.com/jashkenas/docco/issues/201.
+ * Since the CoffeeScript to TypeScript conversion, "docco" isn't used anymore.
+ *
+ * Supports extra validations related to the beanvalidator module.
+ */
+import _ from "underscore";
+import dom from "t5/core/dom.js"
+import events from "t5/core/events.js"
+import utils from "t5/core/utils.js"
+import validation from "t5/core/validation.js";
 
-    const doRangeValidate = function(element, value, memo) {
-      const min = rangeValue(element, "data-range-min", 0);
-      const max = rangeValue(element, "data-range-max", Number.MAX_VALUE);
+const rangeValue = function(element, attribute, defaultValue) {
+  const v = element.attr(attribute);
+  if (v === null) {
+    return defaultValue;
+  } else {
+    return parseInt(v);
+  }
+};
 
-      // If the translated value is still a string, and not a number, then the
-      // size refers to the length of the string, not its numeric value.
-      if (_.isString(value)) {
-        value = value.length;
-      }
+const countOptions = function(e) {
+  // A select that is used as part of a palette is different; the validation 
attributes
+  // are attached to the selected (right side) <select>, and anything there 
counts as part
+  // of the selection.
+  if (e.findParent(".palette")) {
+    return e.element.options.length;
+  } else {
+    // An ordinary <select> may have multiple options (the clumsy 
control-click way)
+    return _.filter(e.element.options, o => o.selected).length;
+  }
+};
 
-      if (!(min <= value && value <= max)) {
-        memo.error = (element.attr("data-range-message")) || "RANGE ERROR";
-        return false;
-      }
+const doRangeValidate = function(element, value, memo) {
+  const min = rangeValue(element, "data-range-min", 0);
+  const max = rangeValue(element, "data-range-max", Number.MAX_VALUE);
 
-      return true;
-    };
+  // If the translated value is still a string, and not a number, then the
+  // size refers to the length of the string, not its numeric value.
+  if (_.isString(value)) {
+    value = value.length;
+  }
 
-    dom.onDocument(events.field.optional, "[data-optionality=prohibited]", 
function(event, memo) {
+  if (!(min <= value && value <= max)) {
+    memo.error = (element.attr("data-range-message")) || "RANGE ERROR";
+    return false;
+  }
 
-      if (!utils.isBlank(memo.value)) {
-        memo.error = (this.attr("data-prohibited-message")) || "PROHIBITED";
-        return false;
-      }
+  return true;
+};
 
-      return true;
-    });
+dom.onDocument(events.field.optional, "[data-optionality=prohibited]", 
function(event, memo) {
 
-    dom.onDocument(events.field.validate, "input[data-range-min], 
input[data-range-max], textarea[data-range-min], textarea[data-range-max]", 
function(event, memo) {
-      return doRangeValidate(this, memo.translated, memo);
-    });
+  if (!utils.isBlank(memo.value)) {
+    memo.error = (this.attr("data-prohibited-message")) || "PROHIBITED";
+    return false;
+  }
 
-    dom.onDocument(events.field.validate, "select[data-range-min], 
select[data-range-max]", function(event, memo) {
-      return doRangeValidate(this, (countOptions(this)), memo);
-    });
+  return true;
+});
 
+dom.onDocument(events.field.validate, "input[data-range-min], 
input[data-range-max], textarea[data-range-min], textarea[data-range-max]", 
function(event, memo) {
+  return doRangeValidate(this, memo.translated, memo);
 });
+
+dom.onDocument(events.field.validate, "select[data-range-min], 
select[data-range-max]", function(event, memo) {
+  return doRangeValidate(this, (countOptions(this)), memo);
+});
\ No newline at end of file

Reply via email to