Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Migrate to @beemo/dev. #34

Merged
merged 5 commits into from Aug 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions .config/beemo.ts
@@ -0,0 +1,15 @@
export default {
module: '@beemo/dev',
drivers: [
'eslint',
'jest',
'prettier',
[
'typescript',
{
buildFolder: 'dts',
declarationOnly: true,
},
],
],
};
9 changes: 9 additions & 0 deletions .config/beemo/eslint.ts
@@ -0,0 +1,9 @@
export default {
rules: {
// All the criteria dont return
'consistent-return': 'off',

// We assign to state a lot
'no-param-reassign': 'off',
},
};
92 changes: 46 additions & 46 deletions docs/guides.md
Expand Up @@ -12,13 +12,13 @@ and must return the same type. Extremely useful for conditional defaults.

```ts
optimal(
{},
{
strict: bool(),
level: string('low').oneOf(['low', 'high']),
// Factory function
level: string((struct) => (struct.strict ? 'high' : 'low')).oneOf(['low', 'high']),
},
{},
{
strict: bool(),
level: string('low').oneOf(['low', 'high']),
// Factory function
level: string((struct) => (struct.strict ? 'high' : 'low')).oneOf(['low', 'high']),
},
);
```

Expand All @@ -35,11 +35,11 @@ use `notNullable()`.

```ts
optimal(
{},
{
callback: func(handler).notNullable(),
settings: object().nullable(),
},
{},
{
callback: func(handler).notNullable(),
settings: object().nullable(),
},
);
```

Expand All @@ -50,13 +50,13 @@ in the struct. Otherwise it throws an error.

```ts
optimal(
{
// Must be defined
name: 'Optimal',
},
{
name: string().required(),
},
{
// Must be defined
name: 'Optimal',
},
{
name: string().required(),
},
);
```

Expand All @@ -67,47 +67,47 @@ requires all related fields to be defined.

```ts
optimal(
{
// Both must be defined
foo: 'abc',
bar: 123,
},
{
foo: string().and('bar'),
bar: number().and('foo'),
},
{
// Both must be defined
foo: 'abc',
bar: 123,
},
{
foo: string().and('bar'),
bar: number().and('foo'),
},
);
```

When `or()` is used, it requires at minimum 1 of any of the fields to be defined.

```ts
optimal(
{
// At minimum 1 defined
baz: true,
},
{
foo: string().or('bar', 'baz'),
bar: number().or('foo', 'baz'),
baz: bool().or('foo', 'bar'),
},
{
// At minimum 1 defined
baz: true,
},
{
foo: string().or('bar', 'baz'),
bar: number().or('foo', 'baz'),
baz: bool().or('foo', 'bar'),
},
);
```

When `xor()` is used, it requires only 1 of any of the fields to be defined.

```ts
optimal(
{
// Only 1 defined
bar: 123,
},
{
foo: string().xor('bar', 'baz'),
bar: number().xor('foo', 'baz'),
baz: bool().xor('foo', 'bar'),
},
{
// Only 1 defined
bar: 123,
},
{
foo: string().xor('bar', 'baz'),
bar: number().xor('foo', 'baz'),
baz: bool().xor('foo', 'bar'),
},
);
```

Expand Down