By calling to .addError() method on the field you want.
Example:
trigger.new[0].Name.addError('Name field does not match the pattern expected'); // where Name is the field, if you want to use custom fields remember to concatenate '__c'. // Note, this is just an example and it is NOT bulk friendly.
By calling to .addError() method on the field you want.
Example:
Regards