Skip to content

Instantly share code, notes, and snippets.

View alexchirea's full-sized avatar
🎯
Focusing

Alex Chirea alexchirea

🎯
Focusing
View GitHub Profile
#include <iostream>
using namespace std;
struct elev {
char nume[20];
float medie;
struct elev *urm;
};
// CMMDC scris in C
#include<stdlib.h>
#include<stdio.h>
int main() {
int a, b, r;
scanf("%d", &a);
scanf("%d", &b);
printf("%d %d", a, b);
r = a % b;
while (r) {
@Entity
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@NotEmpty
@Size(min = 5)
private String fullName;
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
@Repository
public interface PersonRepository extends JpaRepository<Person, Long> { }
@GetMapping("/add")
public String showAddPersonForm(Person person) {
return "add-person";
}
@PostMapping("/add")
public String addPerson(@Valid Person person, BindingResult result, Model model) {
if (result.hasErrors()) {
return "add-person";
}
<div class="alert alert-warning" th:if="${#fields.hasErrors('age')}" th:errors="*{age}"></div>
@NotEmpty(message = "The Full Name can't be null")
@Size(min = 5, message = "{Size.Person.FullName}")
private String fullName;
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.10.Final</version>
</dependency>
@Documented
@Constraint(validatedBy = CustomGoogleEmailValidator.class)
@Target({ ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
public @interface CustomGoogleEmailConstraint {
String message() default "The email must have \"@gmail.com\" extension";
Class[] groups() default {};
Class[] payload() default {};
}