Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mev

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mev - npm Package Compare versions

Comparing version 2.2.2 to 2.2.3

6

lib/field/Field.ts

@@ -1,4 +0,4 @@

import { Rule } from '../rule/Rule';
import { Validation } from '../types/Validation';
import { ValidationRuleError, ValidationRuleResult, ValidationRuleSuccess } from '../types/ValidationRule';
import { Rule } from '../rule';
import { Validation } from '../types';
import { ValidationRuleError, ValidationRuleResult, ValidationRuleSuccess } from '../types';

@@ -5,0 +5,0 @@ export interface FieldOptions {

import { expect } from 'chai';
import 'mocha';
import { createValidationRule } from '..';
import { StringRule } from '../rule/StringRule';
import { createValidationRule, isSuccess } from '..';
import { StringRule } from '../rule';
import { extractRule } from '../test_helpers/field';
import { Validation, ValidationError } from '../types/Validation';
import { Validation, ValidationError } from '../types';
import { isError } from '../utils';

@@ -39,3 +39,12 @@ import { StringField } from './StringField';

});
it('should not fail if undefined', () => {
const emptyValue: undefined = undefined;
const field: StringField = new StringField()
.addRule((r) => r.maxLength(10));
const validation: Validation = field.test(emptyValue);
expect(isSuccess(validation)).to.be.true;
});
});
});

@@ -17,3 +17,3 @@ import { ValidationRuleResult } from '../types/ValidationRule';

public minLength(min: number): this {
this.addInternalTestFunction((str) => str.length >= min, {
this.addInternalTestFunction((str) => str && str.length >= min, {
title: 'too short',

@@ -26,3 +26,3 @@ description: `must be at least ${min} characters long`,

public maxLength(max: number): this {
this.addInternalTestFunction((str) => str.length <= max, {
this.addInternalTestFunction((str) => !str || str.length <= max, {
title: 'too long',

@@ -29,0 +29,0 @@ description: `must not be longer than ${max} characters long`,

import { expect } from 'chai';
import 'mocha';
import { StringRule } from '../rule/StringRule';
import { emptyData, emptyFail, truthyTest } from '../test_helpers/rule';
import { Validation, ValidationError } from '../types/Validation';

@@ -98,3 +97,11 @@ import { Schema } from './Schema';

});
it('should not fail empty or missing fields', () => {
const schema: Schema = new Schema()
.addField('name', (f) => f
.string()
.addRule((r) => r.maxLength(5)),
);
});
});
});
{
"name": "mev",
"version": "2.2.2",
"version": "2.2.3",
"description": "Another validator..",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc