Forum

Ask, reply and learn. Join the community of Akaunting.

New Discussion

Custom validation on existing fields

Sarah Vrielinck   ( User )

Commented 3 years ago

Hey guys,

Perhaps a silly question, but how are you supposed to add custom validation to existing fields? Say you want to add a validator to the tax number field. The existing fields has no validation added, so I guess Validator::extend will not work on it.

I've read somewhere that you can make use of Validator::resolver for this. This works great, until you have other Apps/Modules also making use of this techniques.

Another thing I've been thinking about is hooking the entity perhaps on the saving event. Though that doesn't really feel like the right way to do it. Neither is going the javascript route and validating it client side.

Any suggestions?

Sarah Vrielinck   ( User )

Commented 3 years ago

Found a way around. Seeing an other app was using the resoled. I've used $this->app->afterResolving(ValidatesWhenResolved::class, function($resolved) {}); and added the custom validation in there.

Not the prettiest of solutions but solved the issue we had.

Please login or register to leave a response.

Showing 1 to 2 of 2 discussions