]> git.localhorst.tv Git - alttp.git/blob - resources/js/schema/yup.js
number rounds and results
[alttp.git] / resources / js / schema / yup.js
1 import * as yup from 'yup';
2
3 import { parseTime } from '../helpers/Result';
4
5 yup.addMethod(yup.string, 'time', function (errorMessage) {
6         return this.test('test-time-format', errorMessage, function (value) {
7                 const { path, createError } = this;
8                 return (
9                         parseTime(value) ||
10                         createError({ path, message: errorMessage || 'validation.error.time' })
11                 );
12         });
13 });
14
15 yup.setLocale({
16         mixed: {
17                 default: 'validation.error.general',
18                 required: 'validation.error.required',
19         },
20         string: {
21                 time: 'validation.error.time',
22                 url: 'validation.error.url',
23         },
24 });
25
26 export default yup;