Skip to content

Validation ​

With symfony/validator installed, the ValidCarve constraint checks that a value parses as Carve:

php
use MarkupCarve\SymfonyCarve\Validator\ValidCarve;

final class Comment
{
    #[ValidCarve(preset: 'comment', maxLength: 5000, lint: true)]
    public string $body = '';
}
OptionDefaultDescription
presetnullThe markup has to fit this profile: full, article, comment or minimal.
strictfalseParse warnings count as violations.
lintfalseLint findings count as violations.
maxLengthnullMaximum length in characters.
messagesee belowViolation message; {{ error }} is replaced with the reason.

The default message is This value is not valid Carve markup: {{ error }}. Violation codes are ValidCarve::INVALID_ERROR, TOO_LONG_ERROR and DISALLOWED_ERROR. null and the empty string pass, so combine it with NotBlank when a value is required.

Released under the MIT License.