Namespace: validation

bcdui.widgetNg. validation

validators package, common API all validators share: validator functions are simple functions taking argument object as parameter and returning either NULL (for successful validation) or a validationError object in case of a failed validation. the validationErrorObject properties: validationMessage{i18nToken} validation function MUST not run asynchronously! it is expected to block and return once validation is done. the argument object is arbitrary and defined by particular validation function.

Namespaces

validators

Methods

staticbcdui.widgetNg.validation.addValidityMessage(validationResult, message){object}

widgetNg/validators.js, line 415
appends validity message to validationResult object and returns validationResult, creates a new one if none is provided. message must not be null.
Name Type Description
validationResult object The validationResult object to extend or null to create a new one, this object is modified.
message string | Array.<string> Message to append to the validationResult.validationMessage
Returns:
Type Description
object validationResult object with validationMessage array with appended message(s)

staticbcdui.widgetNg.validation.hasValidStatus()

widgetNg/validators.js, line 402
NO REVALIDATION, just retrieval of current validity state, consideres native (constraint validation api) state and bcdui-internal ( existence of 'bcdInvalid' class). CSS case has to be considered because browsers native validation implementaion may switch validity state so that we cannot detect the change without fully revalidating the field.
Returns:
true if valid, false otherwise

staticbcdui.widgetNg.validation.indicateFieldValidity()

widgetNg/validators.js, line 375
checks the field for validity via html5 constraint validation api and indicate by adding/removing particular CSS classes. The classes are always added, even in case native validation is supported (via :invalid pseudo class)
Returns:
TRUE if validation message has been placed, so field is not valid, false otherwise.

staticbcdui.widgetNg.validation.setCustomValidity()

widgetNg/validators.js, line 349
sets custom validity, use html5 constraint validation API if available, otherwise polyfill, ensures that following properties are set properly: (Boolean) validity.valid (Boolean) validity.customError (String) validationMessage (is set to "INVALID") in case of non-validity

staticbcdui.widgetNg.validation.validateField(htmlElementId, customValidationMessages, skipNativeValidation)

widgetNg/validators.js, line 263
this function carries out validation via native html5 constraint validation api (if available and not suppressed) and optionally marks the field as invalid in case customValidationMessages are provided (i.e. already has been validation with custom validators), additionally it displays the validationMessages to the user. Also resets the field to valid if neither customValidationMessages has been provided nor native validation has returned negative result.
Name Type Default Description
htmlElementId string | element validatable element
customValidationMessages Array.<string> An array of custom validation messages to display for this element (optional)
skipNativeValidation boolean false optional If you want to skip implicit, native html5 validation on the element.
Returns:
TRUE if field has been validated and has no errors, false otherwise