Skip to content

Commit 1a7ae4e

Browse files
committed
added hook to get validatedFormData without triggering another validation cycle
1 parent d722ed0 commit 1a7ae4e

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ def commonSettings: Project => Project =
33
_.enablePlugins(ScalaJSPlugin)
44
.settings(
55
organization := "com.github.torstenrudolf.scalajs-react-form-binder",
6-
version := "0.0.17",
6+
version := "0.0.18-SNAPSHOT",
77
homepage := Some(url("https://github.com/torstenrudolf/scalajs-react-form-binder")),
88
licenses += ("MIT", url("https://opensource.org/licenses/MIT")),
99
scalaVersion := "2.11.8",

core/src/main/scala/torstenrudolf/scalajs/react/formbinder/Form.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ trait Form[DataModel] {
99

1010
def validatedFormData: Option[DataModel]
1111

12+
def validatedFormDataNew(reValidate: Boolean): Option[DataModel]
13+
1214
def field[T](fd: FormFieldDescriptor[T]): ReactNode
1315

1416
def globalValidationResult: Option[ValidationResult]

core/src/main/scala/torstenrudolf/scalajs/react/formbinder/Macros.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,11 @@ trait FormAPI[T] extends Form[T] {
502502
_validatedFormData
503503
}
504504

505+
override def validatedFormDataNew(reValidate: Boolean): Option[T] = {
506+
if (reValidate) validatedFormData
507+
else _validatedFormData
508+
}
509+
505510
private def allFieldValidationResults: List[ValidationResult] = allFormFieldBindingsWithUnderlyingDataField.map(
506511
_.currentValidationResult match {
507512
case Success(vr) => vr

0 commit comments

Comments
 (0)