dev-master
9999999-dev https://github.com/aight8/draft-php-validatorA library which validates and clean the ContentState
MIT
The Requires
The Development Requires
by Sebastian Fekete
A library which validates and clean the ContentState
A validation library which build on top of the draft-php library., (*1)
This library validates the content state by the given configuration., (*3)
Optional: Additionally it can Autofix invalid content states if possible., (*4)
The default configuration of the ValidatorConfig is lazy and contains only the very basics., (*5)
public function __construct(array $config = null)
The passed configuration array can contains following options:, (*6)
Configuration key | Type | Description | Default value |
---|---|---|---|
content_block_max_depth | ... | int | 4 |
content_block_types | ... | string[]? | Defaults::BLOCK_TYPES |
inline_styles | ... | string[]? | Defaults::INLINE_STYLES |
entity_types | ... | string[]? | [] |
entity_validator | ... | callback(DraftEntity):DraftEntity? | null |
block_types_with_depth | ... | string[]? | Defaults::LIST_BLOCK_TYPES |
incremental_depth_steps | ... | bool | true |
max_character_count | ... | int? | null |
max_word_count | ... | int? | null |
max_line_count | ... | int? | null |
content_block_types
, inline_styles
, entity_types
, block_types_with_depth
have
all a default value (the default constants in draft.js).
- If one of those values is set to null
- then everything is allowed.
- If one of those values is set to []
then nothing is allowed., (*7)
The relevant validation function is this one:, (*8)
public function validate(ContentState $contentState, $validatorConfig = null, $tryAutoFix = null)
If the third parameter tryAutoFix
is true, it autofixes all invalid catches.
Excepted for character/word/line limitations! This will always throw an exception., (*9)
If tryAutoFix
is false then it always throws an exception on the first invalid catch., (*10)
By default autofix is enabled because this is the most common use case., (*11)
A library which validates and clean the ContentState
MIT