Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class Violations

  1. Object
  2. Violations
Collects the FieldErrors of one request. The generated validation code calls it; an application has no reason to.

Constructors

public Violations()

Methods

public void add(String field, String code, String message, String fallback)Records one failure.
public List<FieldError> errors()What was recorded so far.
public void check()Throws a ValidationException when anything was recorded.
public static String path(String prefix, String name)prefix.name, or name at the root.
public static String index(String prefix, int index)prefix[index].
public static boolean isBlank(CharSequence s)Whether s is null or only whitespace.

Inherited methods

Constructor details

Violations

public Violations()

Method details

add

public void add(String field, String code, String message, String fallback)
Records one failure.

Parameters

field String
the path
code String
the constraint’s simple name
message String
the declared message, or empty for fallback
fallback String
the default message

errors

public List<FieldError> errors()
What was recorded so far.

Returns

the errors, possibly empty

check

public void check()
Throws a ValidationException when anything was recorded.

path

public static String path(String prefix, String name)
prefix.name, or name at the root.

Parameters

prefix String
the parent path, empty at the root
name String
the property

Returns

the path

index

public static String index(String prefix, int index)
prefix[index].

Parameters

prefix String
the collection’s path
index int
the element

Returns

the path

isBlank

public static boolean isBlank(CharSequence s)
Whether s is null or only whitespace.

Parameters

s CharSequence
the value

Returns

true when blank