mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
framework: add support for passing schemastery as validator
This commit is contained in:
3 files changed
+63
-22
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import { expect } from 'chai';
|
||||
import { describe, it } from 'node:test';
|
||||
import { Types } from '../validator';
|
||||
|
||||
const k = Symbol.for('schemastery');
|
||||
|
||||
describe('validator', () => {
|
||||
it('NumericArray', () => {
|
||||
expect(Types.NumericArray('1,2,3')).to.deep.equal([1, 2, 3]);
|
||||
expect(Types.NumericArray([1, 2, 3])).to.deep.equal([1, 2, 3]);
|
||||
expect(() => Types.NumericArray('123a')).to.throw();
|
||||
});
|
||||
|
||||
it('CommaSeperatedArray', () => {
|
||||
expect(Types.CommaSeperatedArray('1,2,3')).to.deep.equal(['1', '2', '3']);
|
||||
expect(Types.CommaSeperatedArray([1, 2, 3])).to.deep.equal(['1', '2', '3']);
|
||||
expect(Types.CommaSeperatedArray('123a')).to.deep.equal(['123a']);
|
||||
expect(k in Types.CommaSeperatedArray).to.eq(true);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user