flow php

UNIFIED DATA PROCESSING FRAMEWORK

composer require flow-php/etl ~0.32.0

ChangelogRelease Cycle

play Try Playground

elephant
extract

Extracts

Read from various data sources.

arrow
transform

Transforms

Shape and optimize for your needs.

arrow
load

Loads

Store and secure in one of many available data sinks.

Examples:

Description

Type validation checks if a value matches the expected type without throwing exceptions. The isValid() method returns true if the value conforms to the type, false otherwise. This is useful for conditional logic, filtering data, or performing pre-flight checks before processing.

Unlike assertions, validation never throws - it's designed for control flow decisions rather than enforcing contracts.


Validate XML documents. Returns true for well-formed XML strings and DOMDocument objects.

Documentation

Code

play
<?php

declare(strict_types=1);

use function Flow\Types\DSL\type_xml;

require __DIR__ . '/vendor/autoload.php';

$validXml = '<?xml version="1.0"?><root><item>value</item></root>';
$invalidXml = '<root><unclosed>';

echo 'Is valid XML valid? ' . (type_xml()->isValid($validXml) ? 'yes' : 'no') . "\n";
echo 'Is invalid XML valid? ' . (type_xml()->isValid($invalidXml) ? 'yes' : 'no') . "\n";
echo 'Is DOMDocument valid? ' . (type_xml()->isValid(new \DOMDocument()) ? 'yes' : 'no') . "\n";
echo 'Is empty string valid? ' . (type_xml()->isValid('') ? 'yes' : 'no') . "\n";

Contributors

Join us on GitHub external resource
scroll back to top