#66 set minimum

This commit is contained in:
cupcakearmy 2022-11-12 13:42:09 +01:00
parent 0db3ef4a1f
commit 9d13e607f5
No known key found for this signature in database
GPG Key ID: 3235314B4D31232F
2 changed files with 3 additions and 2 deletions

View File

@ -49,7 +49,7 @@ async fn create(note: web::Json<Note>) -> impl Responder {
} }
match n.views { match n.views {
Some(v) => { Some(v) => {
if v > *config::MAX_VIEWS { if v > *config::MAX_VIEWS || v < 1 {
return bad_req; return bad_req;
} }
n.expiration = None; // views overrides expiration n.expiration = None; // views overrides expiration

View File

@ -18,8 +18,9 @@
bind:value={note.views} bind:value={note.views}
disabled={timeExpiration} disabled={timeExpiration}
max={$status?.max_views} max={$status?.max_views}
min={1}
validate={(v) => validate={(v) =>
($status && v <= $status?.max_views) || ($status && v <= $status?.max_views && v > 0) ||
$t('home.errors.max', { values: { n: $status?.max_views ?? 0 } })} $t('home.errors.max', { values: { n: $status?.max_views ?? 0 } })}
/> />
<div class="middle-switch"> <div class="middle-switch">