FloatData example

$validate = new PrimitiveTypeConstraintValidator();
    $validate->initialize($context);
    $validate->validate($value$constraint);
  }

  public function provideTestValidate() {
    $data = [];
    $data[] = [new BooleanData(DataDefinition::create('boolean')), NULL, TRUE];

    $data[] = [new BooleanData(DataDefinition::create('boolean')), 1, TRUE];
    $data[] = [new BooleanData(DataDefinition::create('boolean')), 'test', FALSE];
    $data[] = [new FloatData(DataDefinition::create('float')), 1.5, TRUE];
    $data[] = [new FloatData(DataDefinition::create('float')), 'test', FALSE];
    $data[] = [new IntegerData(DataDefinition::create('integer')), 1, TRUE];
    $data[] = [new IntegerData(DataDefinition::create('integer')), 1.5, FALSE];
    $data[] = [new IntegerData(DataDefinition::create('integer')), 'test', FALSE];
    $data[] = [new StringData(DataDefinition::create('string')), 'test', TRUE];
    $data[] = [new StringData(DataDefinition::create('string'))new TranslatableMarkup('test'), TRUE];
    // It is odd that 1 is a valid string.     // $data[] = [$this->createMock('Drupal\Core\TypedData\Type\StringInterface'), 1, FALSE];     $data[] = [new StringData(DataDefinition::create('string'))[], FALSE];
    $data[] = [new Uri(DataDefinition::create('uri')), 'http://www.example.com', TRUE];
    $data[] = [new Uri(DataDefinition::create('uri')), 'https://www.example.com', TRUE];
    
Home | Imprint | This part of the site doesn't use cookies.