我正在尝试使用React和Formik进行验证。我想实现最大位数仅为2,最大范围应仅为12。
@SpringBootTest
@AutoConfigureJdbc
public class SampleTests {
@Autowired
BookRepository bookRepository;
@Autowired
AuthorRepository authorRepository;
@Test
public void createDeleteBook() {
Author apj = new Author("APJ");
apj = authorRepository.save(apj);
Author arun = new Author("Arun Tiwari");
arun = authorRepository.save(arun);
Book book = new Book("Wings of Fire");
book.addAuthor(apj);
book.addAuthor(arun);
bookRepository.save(book);
}
}
答案 0 :(得分:0)
您可以使用此:
yup.string()
.required("Select month")
.min(2, "Invalid month format (Example: 06)")
.max(2, "Invalid month format (Example: 06)")
.matches(/^(0?[1-9]|1[012])$/, "Month must be greater than 0 and can't be exceeded 12");