Skip to content
This repository has been archived by the owner on Oct 20, 2021. It is now read-only.

Latest commit

 

History

History
21 lines (16 loc) · 676 Bytes

sorted.md

File metadata and controls

21 lines (16 loc) · 676 Bytes

Sorted

Validates if the given input is sorted.

Valid values:

validator.sorted().validate([1, 2, 3]);
validator.sorted(null, false).validate([3, 2, 1]);
validator.sorted((obj: any) => obj.key).validate({a: {key: 1}, b: {key: 2}, c: {key: 3}});
validator.sorted((obj: any) => obj.key, false).validate({c: {key: 'c'}, b: {key: 'b'}, a: {key: 'a'}});

Invalid values:

validator.sorted().validate([3, 2, 1]);
validator.sorted(null, false).validate([1, 2, 3]);
validator.sorted((obj: any) => obj.key).validate({c: {key: 'c'}, b: {key: 'b'}, a: {key: 'a'}});
validator.sorted((obj: any) => obj.key, false).validate({a: {key: 1}, b: {key: 2}, c: {key: 3}});