Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UndefinedConstraint.php

function UndefinedConstraint::shouldApplyDefaultValue

Check whether a default should be applied for this value

Parameters

mixed $schema:

mixed $parentSchema:

bool $requiredOnly:

Return value

bool

1 call to UndefinedConstraint::shouldApplyDefaultValue()
UndefinedConstraint::applyDefaultValues in vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.php
Apply default values

File

vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.php, line 211

Class

UndefinedConstraint
The UndefinedConstraint Constraints

Namespace

JsonSchema\Constraints

Code

private function shouldApplyDefaultValue($requiredOnly, $schema, $name = null, $parentSchema = null) {
    // required-only mode is off
    if (!$requiredOnly) {
        return true;
    }
    // draft-04 required is set
    if ($name !== null && isset($parentSchema->required) && is_array($parentSchema->required) && in_array($name, $parentSchema->required)) {
        return true;
    }
    // draft-03 required is set
    if (isset($schema->required) && !is_array($schema->required) && $schema->required) {
        return true;
    }
    // default case
    return false;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal