Skip to content
Roberto Prevato edited this page Dec 28, 2017 · 26 revisions

This page describes all exception raised by DataEntry library. Exceptions thrown by DataEntry library contain a link to this page. This approach is useful to provide a better description and detailed instructions written comfortably in the GitHub wiki.

1

Missing implementation of Promise. The DataEntry library requires either the ES6 Promise objects to be implemented by the browser, or a polyfill to be loaded.

How to resolve: For browsers that do not implement native Promise objects yet, download a ES6 compatible polyfill. The DataEntry library has been tested with: https://github.com/stefanpenner/es6-promise.

Example of fallback:

  <script>
    (function () {
      if (!window.Promise) {
        var head = document.getElementsByTagName("head")[0];
        var a = document.createElement("script");
        a.type = "text/javascript";
        a.src = "scripts/libs/polyfills/es6-promise.min.js";
        head.appendChild(a);
      }
    })();
  </script>

2

Missing required parameter. This error is raised inside constructors or other functions that didn't receive expected parameters.

How to resolve: Pass required parameters to the function that is raising the exception.

3

Missing validation rule definition. A dataentry schema has been configured to use a validation rule, which is not defined inside the Forms.Validation.Rules object.

How to resolve: Either define the validation rule inside the Forms.Validation.Rules object, or correct the dataentry schema.

4

Missing formatting rule definition. A dataentry schema has been configured to use a formatting rule, which is not defined inside the Forms.Formatting.Rules object.

How to resolve: Either define the formatting rule inside the Forms.Formatting.Rules object, or correct the dataentry schema.

5

Missing constraint rule definition. A dataentry schema has been configured to use a constraint rule, which is not defined inside the Forms.Constraints object.

How to resolve: Either define the constraint rule inside the Forms.Constraints object, or correct the dataentry schema.

6

Missing name in validation rule schema. Inside the DataEntry schema object, a validation rule has been defined as an object, but its name is missing or falsy.

How to resolve: Correct the DataEntry schema validation definition for the property that is causing the exception. Example of wrong configuration:

exampleProperty: {
  validation: [{ namez: "remote", params: [function () { ... }]}] // WRONG
}

Example of proper configuration:

exampleProperty: {
  validation: [{ name: "remote", params: [function () { ... }]}]
}

7

Missing promise provider. This error is specific to the remote validation rule, which is defined among the basic validation rules. The cause of the error is that the remote validation rule has been used without defining the function that returns a Promise.

How to resolve: Define the function that returns the Promise object, for the remote validation rule configured in the DataEntry schema:

exampleProperty: {
  validation: [{ name: "remote", params: [function () { ... }]}]
}

8

Invalid parameters for DataEntry constructor. This exception is raised if invalid parameters are passed to the constructor of a DataEntry object, it can be caused by one of these situations:

  • missing options (i.e. null, undefined or falsy object passed to the constructor function)
  • missing element
  • missing schema

How to resolve: Instantiate a DataEntry passing the required options, for example:

var dataentry = new Forms.DataEntry({
  element: document.getElementById("form"),
  schema: {
    name: {
      validation: ["required"],
      format: ["cleanSpaces"]
    },
    year: {
      validation: ["required", { name: "integer", params: [{ min: 1900, max: 2015 }] }]
    }
  }
});

9

Invalid parameter: fields must be an array of strings. This function is specific to the validate function of the DataEntry prototype.

How to resolve: When specifying a parameter for the fields to be validated, possible values are:

  • an array of strings representing names of properties
  • a function returning an array of strings representing names of properties

10

Missing element in the function scope. This exception may happen, for example, when calling the validate function over an instance of DataEntry that has been already disposed.

How to resolve: Avoid calling a function when the conditions for its functionality are missing.

11

Missing schema in the function scope. This exception may happen, for example, when calling the validate function over an instance of DataEntry whose schema has been deleted, or set to a falsy value.

How to resolve: Avoid calling a function when the conditions for its functionality are missing. Verify why the scope is missing when the function is called.

12

Missing name in the function scope. This exception may happen, for example, when calling the validateField function over an instance of DataEntry without passing a proper property name.

How to resolve: Verify why a name parameter is missing when the function is called.

13

Cannot validate the field, because the schema object does not contain its definition or its validation definition.

How to resolve: Verify that the field that is being validated, has a validation schema defined inside the dataentry schema.

14

Invalid rule definition. This exception is thrown, when a validation/formatting/constratint rule is not defined as a string (representing the name of a rule), nor as an object with a name property. For example, this exception is raised if a validation rule is defined as an instance of RegExp.

How to resolve: Correct the configuration of the dataentry schema.

15

Missing dataentry context, or missing context.dataentryObjectGetter function. This exception is specific to the ContextHarvester constructor. When using a ContextHarvester (i.e. object that read values from a given object, matching the names of properties defined in validation schema with the properties of the given context), it is necessary to define a function in the dataentry context, that returns the object from which values must be read.

How to resolve: Define the dataentry context, and the dataentryObjectGetter function inside the context.

16

Missing name in formatting/constrating rule schema. Inside the DataEntry schema object, a formatting or a constraint rule has been defined as an object, but its name is missing or falsy.

How to resolve: Correct the DataEntry schema rule definition for the property that is causing the exception. Example of wrong configuration:

exampleProperty: {
  format: [{ namez: "examplename", params: [function () { ... }]}] // WRONG
}

Example of proper configuration:

exampleProperty: {
  format: [{ name: "examplename", params: [function () { ... }]}]
}

17

Missing context for ContextDecorator.

How to resolve: Either provide a context for the instance of DataEntry, or specify an object that should be modified by the ContextDecorator, using validationContext option.

18

Missing context for ContextHarvester.

How to resolve: Either provide a context for the instance of DataEntry, or specify an object that should be modified by the ContextDecorator, using sourceObject option.

19

DOM contains input elements with same name but different type of input. This is not supported by the library.

Example of wrong configuration:

<input type="radio" name="foo" />
<input type="text" name="foo" />

How to resolve: Input with different types should have a different name. Only groups of input elements with the same type, when the same name is used, are supported (e.g. groups of checkboxes or radio buttons with the same name).

20

Missing element for DataEntry and DomBinder.

How to resolve: Provide an HTML element for the instance of DataEntry. Make sure that the element exists when passed as argument to DataEntry constructor's options.

21

Invalid validationTarget for ContextDecorator: the object is the same dataentry context.

How to resolve: When using the ContextDecorator, a validationTarget must be specified and it must be a different object than the dataentry context: otherwise the decorator would override the original values with state information.

22

Invalid localizer for DataEntry: the object does not implement the required localizer interface.

How to resolve: When using the localizer option, its value must be an object implementing these two methods:

  • t - function that, given a string key, returns a localized text
  • lookup - function that, given a string key, returns a value indicating whether a localized text is available for the key

Ref. https://github.com/RobertoPrevato/I.js.

Clone this wiki locally