The Oracle JET framework provides converter classes that convert user input strings into the data type expected by the application and validator classes that enforce a validation rule on those input strings. For example, you can use Oracle JET's oj.IntlDateTimeConverter to convert a user-entered date to a Date object for use by the application's ViewModel and then use oj.DateTimeRangeValidator to validate that input against a specified time range. You can also use converters to convert Date or Number objects to a string suitable for display.
To make it easier to create an Oracle JET converter or validator, the Oracle JET framework provides a factory for each converter and validator. For example, to create an instance of an oj.IntlDateTimeConverter, use oj.IntlDateTimeConverterFactory and call its createConverter() method.
To retrieve the converter or validator factory for a registered type, Oracle JET provides the oj.Validation class which includes methods to register and retrieve converter and validator factories.
If the converters or validators included in the Oracle JET framework are not sufficient for your application, you can create custom converters or validators. Optionally, you can provide a custom factory that implements the contract for a converter using oj.ConverterFactory or a validator using oj.ValidatorFactory and register the converter or validator with the oj.Validation class. The oj.Validation class enables you to access your custom converter or validator using the same mechanisms as you would use with the Oracle JET standard converters and validators.
Topics:
All Oracle JET editable components support a value option and provide UI elements that allow the user to enter or choose a value. These components also support other options that page authors can set that instruct the component how it should validate its value.
An editable component may implicitly create a built-in converter and/or built-in validators for its normal functioning when certain options are set.
For example, editable components that support a required option create the required validator implicitly when the option is set to true. Other components like ojInputDate, ojInputDateTime, and ojInputTime create a datetime converter to implement its basic functionality.
Topics
The following table describes the Oracle JET validators and provides links to the API documentation:
| Validator | Description | Link to API |
|---|---|---|
|
|
Validates that the input date is between two dates, between two times, or within two date and time ranges |
|
|
|
Validates that the input date is not a restricted date |
|
|
|
Validates that an input string is within a specified length |
|
|
|
Validates that an input number is within a specified range |
|
|
|
Validates that the regular expression matches a specified pattern |
|
|
|
Validates that a required entry exists |
The options that a component supports is part of its API, and the following validation specific options apply to most editable components.
| Component Option | HTML5 Attribute | Description |
|---|---|---|
|
|
When specified, the |
|
|
|
|
When specified on the HTML element or as an option on an Oracle JET component like |
|
|
|
When specified on the HTML element or as an option of an Oracle JET component like |
|
|
|
When specified on the HTML element or as an option on an Oracle JET component like |
|
|
|
When specified on the HTML element or as an option on an Oracle JET component, it displays a placeholder in most components. |
|
|
|
When specified on the HTML element or as an option on an Oracle JET component, the component creates an implicit required validator. |
|
|
When specified, the component uses these validators along with the implicit validators to validate the UI value. |
Some editable components do not support specific validation options as they might be irrelevant to its intrinsic functioning. For example, ojRadioset and ojCheckboxset do not support a converter option since there is nothing for the converter to convert. For an exact list of options and how to use them, refer to the Options section in the component's API documentation. For Oracle JET API documentation, see JavaScript API Reference for Oracle® JavaScript Extension Toolkit (JET). Select the component you're interested in viewing from the API list.
Note:
When the element that the Oracle JET component is initialized from also has HTML5 validation attributes, then these often drive the initial value of the corresponding option on the component if the option is not already present.
Oracle JET editable components support the following methods for validation purposes. For details on how to call this method, its parameters and return values, refer to the component’s API documentation for details.
| Component Method | Description |
|---|---|
|
|
Use this method to detect the current validity state of a component. The method returns the boolean |
|
|
Use this method when the DOM the component relies on changes, such as the label associated to the input component. |
|
|
Use this method to reset the component's display value to reflect its stored option value. |
|
|
Use this method to validate the component using the current display value. |
For details on calling a component’s method, parameters, and return values, See the Methods section of the component's API documentation in JavaScript API Reference for Oracle® JavaScript Extension Toolkit (JET). You can also find detail on how to register a callback for or bind to the event and for information about what triggers the events. Select the component you're interested in viewing from the API list.
The Oracle JET converters include date and number converters and are described in the following table.
| Converter | Description | Link to API |
|---|---|---|
|
|
Converts a string to a |
|
|
|
Converts a string to a number or formats a number or |
Note:
Oracle JET does not support input and output of a date-time value in a time zone other than the local time. As a result, the Oracle JET framework can’t parse the ISO string returned by such JavaScript functions astoISOString().