DEV Community

[Comment from a deleted post]
Collapse
 
cesarcodes profile image
Cesar Codes

Hey Miguel, .NET Core has model validation, but this is more for custom things you want to validate manually. How does Laravel handle it?

Collapse
 
apoca profile image
Miguel Vieira

Hi Cesar, Laravel leads with validation in requests, but that also have model validations...

laravel.com/docs/6.x/validation

 
cesarcodes profile image
Cesar Codes

Cool, yeah it seems that the custom validation works the same way as here:

class Uppercase implements Rule
{
    /**
     * Determine if the validation rule passes.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function passes($attribute, $value)
    {
        return strtoupper($value) === $value;
    }

    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return 'The :attribute must be uppercase.';
    }
}

This is basically the same concept as with dotnet core.

 
apoca profile image
Miguel Vieira

Hum cool, can you send me an example more complete ?

Actually, IAM trying to learn more about dotnet core to start doing microservices...