Skip to content

Validator

Nahuel Palumbo edited this page Oct 2, 2022 · 1 revision

Main diagram

Wollok Linter

Components

  • validate: core linter function, called by LSP server thread, and delegates to
  • createDiagnostic: adapter function that converts a wollok-ts Problem into a LSP Diagnostic object. The problem has a code (the function name that failed) and it is converted into a human readable message, using also the language ('en' or 'es', according to settings). Lets say you define this class:
class bird {
}

Since bird should begin with uppercase, you get nameBeginsWithUppercase as a Problem validation code. If you set Spanish Language, we must look for the corresponding message in ValidationMessages array:

const validationMessagesEs: ValidationMessage = {
	'nameBeginsWithUppercase': 'El nombre {0} debe comenzar con mayúsculas', ...

Each validator sends a values array, so {0} is interpolated with this array, resulting in

'El nombre bird debe comenzar con mayúsculas'
Clone this wiki locally