Class ConstraintUtils

java.lang.Object
cz.masci.springfx.mvci.util.constraint.ConstraintUtils

public class ConstraintUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static io.github.palexdev.materialfx.validation.Constraint
    isInRange(javafx.beans.property.IntegerProperty integerProperty, String fieldName, int min, int max)
    Returns a constraint that validates whether the given integer property is within the specified range.
    static io.github.palexdev.materialfx.validation.Constraint
    isNotEmpty(javafx.beans.property.StringProperty stringProperty, String fieldName)
    Returns a constraint that validates whether the given string property is not empty.
    static <T> io.github.palexdev.materialfx.validation.Constraint
    isNotEmptyWhenPropertyIsNotEmpty(javafx.beans.property.StringProperty stringProperty, javafx.beans.property.Property<T> nullableProperty, String fieldName)
    Returns a constraint that validates whether the given string property is not empty when the nullable property is not empty.
    static io.github.palexdev.materialfx.validation.Constraint
    isNumber(javafx.beans.property.StringProperty stringProperty, String fieldName)
    Returns a constraint that validates whether the given string property contains only a number.
    static io.github.palexdev.materialfx.validation.Constraint
    isNumberOrEmpty(javafx.beans.property.StringProperty stringProperty, String fieldName)
    Returns a constraint that validates whether the given string property contains a number or is empty.
    static <T> io.github.palexdev.materialfx.validation.Constraint
    isNumberOrEmptyWhenPropertyIsNotEmpty(javafx.beans.property.StringProperty stringProperty, javafx.beans.property.Property<T> nullableProperty, String fieldName)
    Returns a constraint that validates whether the given string property contains only a number and the nullable property is not empty.
    static <T> io.github.palexdev.materialfx.validation.Constraint
    isNumberWhenPropertyIsNotEmpty(javafx.beans.property.StringProperty stringProperty, javafx.beans.property.Property<T> nullableProperty, String fieldName)
    Returns a constraint that validates whether the given string property contains only a number and the nullable property is not empty.
    static <T, U extends io.github.palexdev.materialfx.validation.Validated>
    io.github.palexdev.materialfx.validation.Constraint
    isValid(String fieldName, javafx.beans.value.ObservableValue<T> parent, Function<T,javafx.beans.value.ObservableValue<U>> childMap)
    Returns a constraint that validates whether the child property is valid when the parent is set.
    static void
    setLocale(Locale locale)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConstraintUtils

      public ConstraintUtils()
  • Method Details

    • setLocale

      public static void setLocale(Locale locale)
    • isNotEmpty

      public static io.github.palexdev.materialfx.validation.Constraint isNotEmpty(javafx.beans.property.StringProperty stringProperty, String fieldName)
      Returns a constraint that validates whether the given string property is not empty.
      Parameters:
      stringProperty - the string property to validate
      fieldName - the field name used in error message for the constraint
      Returns:
      a constraint that validates whether the given string property is not empty
    • isInRange

      public static io.github.palexdev.materialfx.validation.Constraint isInRange(javafx.beans.property.IntegerProperty integerProperty, String fieldName, int min, int max)
      Returns a constraint that validates whether the given integer property is within the specified range.
      Parameters:
      integerProperty - the integer property to validate
      fieldName - the field name used in the error message for the constraint
      min - the minimum value of the range (inclusive)
      max - the maximum value of the range (inclusive)
      Returns:
      a constraint that validates whether the given integer property is within the specified range
    • isNumber

      public static io.github.palexdev.materialfx.validation.Constraint isNumber(javafx.beans.property.StringProperty stringProperty, String fieldName)
      Returns a constraint that validates whether the given string property contains only a number.
      Parameters:
      stringProperty - the string property to validate
      fieldName - the field name used in the error message for the constraint
      Returns:
      a constraint that validates whether the given string property contains only a number
    • isNumberOrEmpty

      public static io.github.palexdev.materialfx.validation.Constraint isNumberOrEmpty(javafx.beans.property.StringProperty stringProperty, String fieldName)
      Returns a constraint that validates whether the given string property contains a number or is empty.
      Parameters:
      stringProperty - the string property to validate
      fieldName - the field name used in the error message for the constraint
      Returns:
      a constraint that validates whether the given string property contains only a number
    • isNotEmptyWhenPropertyIsNotEmpty

      public static <T> io.github.palexdev.materialfx.validation.Constraint isNotEmptyWhenPropertyIsNotEmpty(javafx.beans.property.StringProperty stringProperty, javafx.beans.property.Property<T> nullableProperty, String fieldName)
      Returns a constraint that validates whether the given string property is not empty when the nullable property is not empty. It is TRUE when nullable property is empty.
      Type Parameters:
      T - Type of the nullable property
      Parameters:
      stringProperty - the string property to validate
      nullableProperty - the nullable property
      fieldName - the field name used in error message for the constraint
      Returns:
      a constraint that validates whether the given string property is not empty
    • isNumberWhenPropertyIsNotEmpty

      public static <T> io.github.palexdev.materialfx.validation.Constraint isNumberWhenPropertyIsNotEmpty(javafx.beans.property.StringProperty stringProperty, javafx.beans.property.Property<T> nullableProperty, String fieldName)
      Returns a constraint that validates whether the given string property contains only a number and the nullable property is not empty. It is TRUE when nullable property is empty.
      Type Parameters:
      T - Type of the nullable property
      Parameters:
      stringProperty - the string property to validate
      nullableProperty - the nullable property
      fieldName - the field name used in the error message for the constraint
      Returns:
      a constraint that validates whether the given string property contains only a number
    • isNumberOrEmptyWhenPropertyIsNotEmpty

      public static <T> io.github.palexdev.materialfx.validation.Constraint isNumberOrEmptyWhenPropertyIsNotEmpty(javafx.beans.property.StringProperty stringProperty, javafx.beans.property.Property<T> nullableProperty, String fieldName)
      Returns a constraint that validates whether the given string property contains only a number and the nullable property is not empty. It is TRUE when nullable property is empty.
      Type Parameters:
      T - Type of the nullable property
      Parameters:
      stringProperty - the string property to validate
      nullableProperty - the nullable property
      fieldName - the field name used in the error message for the constraint
      Returns:
      a constraint that validates whether the given string property contains only a number
    • isValid

      public static <T, U extends io.github.palexdev.materialfx.validation.Validated> io.github.palexdev.materialfx.validation.Constraint isValid(String fieldName, javafx.beans.value.ObservableValue<T> parent, Function<T,javafx.beans.value.ObservableValue<U>> childMap)
      Returns a constraint that validates whether the child property is valid when the parent is set.
      Type Parameters:
      T - Type of the parent observable value
      U - Type of the child observable value
      Parameters:
      fieldName - error message for the constraint
      parent - the parent object from which the child property is taken
      childMap - the child object mapper
      Returns:
      a constraint that validates whether the child property satisfies to the test