Skip to content

Custom error messages #677

Closed
Closed
@rudiedirkx

Description

@rudiedirkx

How do we feel about custom error message like some other libraries have:

[
	'type' => 'string',
	'pattern' => '^[sr]-\d+$',
	'message' => [
		'pattern' => 'Invalid sport/resource format, expected "s" or "r" + ID',
	],
],

Would use message.pattern if the pattern constraint failed.

I started with a PR for 5.2.11, but that's not how master works anymore, because every error is a ConstraintError now, which makes custom impossible by enum definition. Don't how how to approach it now. addError() knows the failed constraint, but not the element's schema/message item.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions