Open Journal Systems  3.3.0
ValidatorFactory Class Reference

Static Public Member Functions

static allowedLocales ($validator, $multilingualProps, $allowedLocales)
 
static convertMessageSyntax ($message)
 
static getMessages ($messages=[])
 
static make ($props, $rules, $messages=[])
 
static required ($validator, $action, $requiredProps, $multilingualProps, $allowedLocales, $primaryLocale)
 
static temporaryFilesExist ($validator, $uploadProps, $multilingualUploadProps, $props, $allowedLocales, $userId)
 

Detailed Description

A factory class for creating a Validator from the Laravel framework.

Definition at line 24 of file ValidatorFactory.inc.php.

Member Function Documentation

◆ allowedLocales()

static ValidatorFactory::allowedLocales (   $validator,
  $multilingualProps,
  $allowedLocales 
)
static

A wrapper method that calls $validator->after to check for data from locales that are not allowed

Parameters
$validatorIlluminate\Validation\Validator
$multilingualPropsarray List of prop names
$allowedLocalesarray List of locale codes

Definition at line 320 of file ValidatorFactory.inc.php.

Referenced by PKP\Services\PKPSiteService\validate(), PKP\Services\PKPAuthorService\validate(), PKP\Services\PKPAnnouncementService\validate(), PKP\Services\PKPEmailTemplateService\validate(), PKP\Services\PKPContextService\validate(), APP\Services\GalleyService\validate(), PKP\Services\PKPPublicationService\validate(), and PKP\Services\PKPSubmissionService\validate().

◆ convertMessageSyntax()

static ValidatorFactory::convertMessageSyntax (   $message)
static

Convert variables in translated strings from {$variable} syntax to Laravel's :variable syntax

Parameters
$messagestring
Returns
string

Definition at line 238 of file ValidatorFactory.inc.php.

Referenced by getMessages().

◆ getMessages()

static ValidatorFactory::getMessages (   $messages = [])
static

Compile translated error messages for each of the validation rules we support.

Parameters
$messagesarray List of error messages to override the defaults.
Returns
array

Definition at line 138 of file ValidatorFactory.inc.php.

References convertMessageSyntax().

Referenced by make().

◆ make()

static ValidatorFactory::make (   $props,
  $rules,
  $messages = [] 
)
static

Create a validator

This is a wrapper function for Laravel's validator factory. It loads the necessary dependencies and instantiates Laravel's validation factory, then calls the make method on that factory.

Parameters
$propsarray The properties to validate
$rulesarray The validation rules
$messagesarray Error messages
Returns
Illuminate\Validation\Validator

Definition at line 38 of file ValidatorFactory.inc.php.

References getMessages().

Referenced by APIHandler\_validateStatDates(), ValidatorEmail\isValid(), ValidatorISSN\isValid(), ValidatorORCID\isValid(), ValidatorUrl\isValid(), ValidatorRegExp\isValid(), MetadataProperty\isValid(), PKP\Services\PKPSiteService\validate(), PKP\Services\PKPAuthorService\validate(), PKP\Services\PKPAnnouncementService\validate(), PKP\Services\PKPEmailTemplateService\validate(), PKP\Services\PKPContextService\validate(), APP\Services\GalleyService\validate(), PKP\Services\PKPPublicationService\validate(), and PKP\Services\PKPSubmissionService\validate().

◆ required()

static ValidatorFactory::required (   $validator,
  $action,
  $requiredProps,
  $multilingualProps,
  $allowedLocales,
  $primaryLocale 
)
static

A wrapper method that calls $validator->after to check if required props are present

When adding an object, required props must be present in the list of props being passed for validation. When editing an object, required props may be absent if they are not being edited. But if a required prop is present it can not be empty.

Required props that are also multilingual will only be required in the primary locale.

Parameters
$validatorIlluminate\Validation\Validator
$actionstring One of VALIDATE_ACTION_* constants
$requiredPropsarray List of prop names
$multilingualPropsarray List of prop names
$allowedLocalesarray List of locale codes
$primaryLocalestring Primary locale code

Definition at line 261 of file ValidatorFactory.inc.php.

References PKPLocale\getAllLocales().

Referenced by PKP\Services\PKPSiteService\validate(), PKP\Services\PKPAuthorService\validate(), PKP\Services\PKPAnnouncementService\validate(), PKP\Services\PKPEmailTemplateService\validate(), PKP\Services\PKPContextService\validate(), APP\Services\GalleyService\validate(), PKP\Services\PKPPublicationService\validate(), and PKP\Services\PKPSubmissionService\validate().

◆ temporaryFilesExist()

static ValidatorFactory::temporaryFilesExist (   $validator,
  $uploadProps,
  $multilingualUploadProps,
  $props,
  $allowedLocales,
  $userId 
)
static

A wrapper method that validates the temporaryFileId of new file uploads when an object is edited

Parameters
$validatorIlluminate\Validation\Validator
$uploadPropsarray List of prop names that may include a a temporaryFileId
$multilingualUploadPropsarray List of $uploadProps which are multiligual
$propsarray Key/value list of props
$allowedLocalesarray List of locale codes
$userIdint The user ID which owns the temporary files

Definition at line 354 of file ValidatorFactory.inc.php.

Referenced by PKP\Services\PKPSiteService\validate().


The documentation for this class was generated from the following file: